Forum Moderators: phranque

Message Too Old, No Replies

Redirect sub-directory to sub-domain

Move site that used to be located in a domain sub-directory to a new sub-do

         

erikcw

7:30 pm on Mar 27, 2004 (gmt 0)

10+ Year Member



Hi All,

I am trying to get a RewriteRule to work, but it doesn't seem to want to no matter what I do.

I want an old site located at www.domain.com/sites/sitename.com/... to mod-rewrite it's contents to
sitename.domain.com/...
(NOTE: There are nine sites that I am moving like this - so a dynamic solution is prefered.)

This is the rule I put in my htaccess:
RewriteRule sites\/(.*)\.com\/(.*)$ [$1.themms.com...] [r]

Unfortunatly it just displays the old site, and doesn't redirect. It is important that the site be able to preserve its PR.

Thanks for your help!

jdMorgan

12:15 am on Mar 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your code looks basically OK, and may just need a preamble and maybe a few tweaks. For use in your top-level .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^sites/([^.]*)\.com(.*)$ http://$1.thenewdomain.com$2 [R=301,L]

If you want to use it in httpd.conf, use:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/sites/([^.]*)\.com(.*)$ http://$1.thenewdomain.com$2 [R=301,L]

Jim