Jump to content

.htaccess mod rewrite


Destramic

Recommended Posts

hey i want to be able to re write an uri with mod rewrite in the .htaccess file.

 

my directory looks like so:

 

-www

/public

/scripts

.htacess

 

and my files are located in the /public file and to access the url would look like http://domin.com

 

but what i want to do is create a re mod rewrite so when http://domin.com/~scripts is access it will take me out of the /public directory and access /scripts directory (../scripts)

 

can someone help me on how this can be done please...thank you

 

 

Link to comment
https://forums.phpfreaks.com/topic/238355-htaccess-mod-rewrite/
Share on other sites

You don't actually need mod_rewrite.

 

Assuming you're on a Linux server you can just put in a symlink. From a shell,

/path/to/yourfiles $ ln -s scripts 'public/~scripts'

You may need to modify your .htaccess with

Options +FollowSymLinks

No that code is to be used in a command shell for defining the symlink.

 

You first need to open a command terminal move to the directory where you want the symlink and then run the command requinix suggested. Next add Options +FollowSymLinks to a .htaccess file in the public/ directory,

In Windows, on NTFS drives, you can create hardlinks. Basically, the two directories (scripts and public/~scripts) point to the same location on the hard drive: same files, same dates and times, different parent directories.

Find the Command Prompt in the Start menu (check Accessories), right-click, Run as administrator. Then find the directory that contains scripts/ and public, shift+right-click, Copy as path. Back in the command prompt, type

cd /d (now right-click in the window and hit Paste)
fsutil hardlink create public/~scripts scripts

 

For the real server, if it's running Linux, get whoever maintains it to create the symlink I mentioned: from public/~scripts to scripts/.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.