.htaccess - Special 301 redirection rules -
i'm moving old site new domain , i've been trying make proper 301 redirect in .htaccess file accomodate kind of redirection rules below think i'm stumped.
new.com --> new.com/main www.new.com --> new.com/main old.com --> new.com/main www.old.com --> new.com/main old.com/* --> new.com/* www.old.com/* --> new.com/* sub.old.com/* --> sub.new.com/*
for first part, seems code works:
# rewritecond %{http_host} ^new\.com$ [or] # rewritecond %{http_host} ^www\.new\.com$ # rewriterule ^/?$ "http\:\/\/new\.com\/main" [r=301,l] # rewriterule ^$ http://www.new.com/main [r=301,l]
put simple, if browser requests page other old.com domain's homepage, i'd go new.com. if visit new.com, they'd redirected /main folder. however, i'm worried should ever explicitly visit new.com/main, they'd fall infinite redirect.
any appreciated.
this code needed on document_root/.htaccess
on new.com
:
options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewritecond %{http_host} ^(www\.)?new\.com$ [nc] rewriterule ^$ http://new.com/main [r=301,l]
this code needed on document_root/.htaccess
on old.com
:
options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewritecond %{http_host} ^(www\.)?old\.com$ [nc] rewriterule ^$ http://new.com/main [r=301,l] rewritecond %{http_host} ^(www\.)?old\.com$ [nc] rewriterule ^(.+)$ http://new.com/$1 [r=301,l] rewritecond %{http_host} ^([^.]+)\.old\.com$ [nc] rewriterule ^$ http://%1.new.com/main [r=301,l] rewritecond %{http_host} ^([^.]+)\.old\.com$ [nc] rewriterule ^(.+)$ http://%1.new.com/$1 [r=301,l]
Comments
Post a Comment