Web Hosting Talk







View Full Version : redirect directory?


N8Webs
08-18-2005, 01:22 PM
I just moved my site to a new server and the previous server I could set up a 'directory pointer.' In that I moved all the files from one directory to another. To keep any external links I had the server simply point to the new directory.

Eg. www.website.com/directory1/file1.html would simply go to www.website.com/directory2/file1.html

The new server doesn't have that 'built' in. Is there a way to do that with .htaccess files or something else?

To add a redirect to every file in directory1 is impossible - far too many files.

Thanks.

abmcosta
08-19-2005, 05:17 PM
I must confess I am no authority in apache... but adding this to your .htaccess should do the trick:

Redirect /olddirectory http://yoursite.com/newdirectory

N8Webs
08-19-2005, 09:27 PM
awesome simple re-direct.

Anyone know how to modify it so it 'carry' a name of a file such as

/directory1/file

will automatically go to

/directory2/file

In Direct Admin the feature is under Site Redirects. However I'm now under Plesk.

Thanks.

abmcosta
08-23-2005, 09:49 AM
Doesnt the above work?

When accessing:
http://yoursite.com/olddirectory/someotherdir/somefilename.html

you should be redirected automatically to:
http://yoursite.com/newdirectory/someotherdir/somefilename.html

If not... try this instead in you .htaccess:
RedirectMatch temp /olddirectory/(.*) http://yoursite.com/newdirectory/$1

N8Webs
08-23-2005, 09:57 AM
The code:

RedirectMatch temp /olddirectory/(.*) http://yoursite.com/newdirectory/$1

works perfectly for me - thanks!!