开发者

.htaccess domain redirect only domain changing need to keep full url intact

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜