Forum Moderators: phranque

Message Too Old, No Replies

.htaccess redirect

redirect a whole directory to another one

         

moty66

2:27 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



Hello
I just want to write a .htaccess and place it in the root to redirect the visitors of the old directory to a new one
examples

source target
------ ------
example.com/dir example.com/dir2/
example.com/dir/file example.com/dir2/

thanks alot

Longhaired Genius

2:43 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



First: have you actually got spaces in your URL, or is that a typo?

moty66

2:49 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



the redirect should be like this

example.com/dir -> example.com/dir2/
example.com/dir/file.ext -> example.com/dir2/

Longhaired Genius

6:59 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



If I understand you correctly, you want a request for any file that was previously in dir to be directed to the index page of dir2. This will do that:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^dir/.* http://example.com/dir2/ [R=301,L]