So far I have this and it works well. It redirects from:
(www.)myoldsite.com/folder1/folder2/
to
www.newdomain.com
RewriteCond %{HTTP_HOST} ^myoldsite.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.myoldsite.com$
RewriteRule ^folder1\/folder2\/?(.*)$ "http\:\/\/www\.newdomain\.com$1" [R=301,L]
This works fine if people go to:
(www.)myoldsite.com/folder1/folder2
They get redirected but all folders further down the hierarchy are lost.
I need it to redirect but keep its url structure beyond the domain name. E.g.
(www.)myoldsite.com/folder1/folder2/folder3/folder4/file1.html
-->开发者_Python百科 REDIRECT TO -->
www.newdomain.com/folder3/folder4/file1.html
Thank you in advance.
Try this:
RewriteCond %{HTTP_HOST} ^(www\.)?myoldsite\.com$
RewriteRule ^folder1/folder2(/.*)?$ http://www.newdomain.com$1 [R=301,L]
Additionally I've merged the two RewriteConds into one.
精彩评论