Forum Moderators: phranque

Message Too Old, No Replies

Pardon... but 301 redirect question.

from subdirectory to new domain, page by page

         

robertito62

6:22 pm on Jun 29, 2003 (gmt 0)

10+ Year Member



Hello, i read many pages here on how to redirect permanently and have also made a search on 301 and permanent redirects but still can't make mine work, possibly because migration hasn't been completed.

I would still appreciate someone's opinion to see if I am on the right track and I apologize if this has been discussed before (I truly couldn't find a specific thread on the first 4 result pages, searching WW).

On trying to transfer an entire subdirectory from an old domain to a new domain I placed an .htaccess file at the root of the original domain like this:

redirect permanent /subdirectory/file1.html [newdomain.com...]

The subdirectory at the old domain has 200 pages, all named differently which should be at the root of the new domain. Does this mean I will have to write 200 command lines, one for each redirected file?

Thank you for any help.

ewanfisher

7:05 pm on Jun 29, 2003 (gmt 0)

10+ Year Member



Place the following code in a .htaccess file on the old domain. It should do the trick for you :)

RewriteEngine on
RewriteBase /subdirectory/
RewriteRule ^subdirectory(.+) [newdomain.com$1...] [L,R=301]

This basically tells your web server to catch all requests for files in "subdirectory", make a note of the file name, and issue a 301 header to the browser with a redirect to "newdomain.com/file name".

Hope this helps,
Ewan

robertito62

7:34 pm on Jun 29, 2003 (gmt 0)

10+ Year Member



That is exactly what I wanted. Thanks.

ewanfisher

7:37 pm on Jun 29, 2003 (gmt 0)

10+ Year Member



cool! :) Glad I could help.