在根目录中的代码已经工作(例如):
RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldsite.co.uk [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldsite.co.uk [NC]
RewriteRule ^(.*)$ https://www.NEW111NEW.com/$1 [L,R=301,NC]
现在我需要重新导向子网域(例如):
从:https://info.oldsite.co.uk/blog/some-blog-post-a
至:https://info.NEW111NEW.com/blog/some-blog-post-a
我试了- 1(不工作):
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^info.oldsite.co.uk [NC]
RewriteRule ^blog/(.*) http://info.NEW111NEW.com/blog/$1 [L,R=301,NC]
还尝试了-2(不工作):
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(info\.)?oldsite\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://info.NEW111NEW.com/blog/$1 [R=302,L]
---更新---
当尝试-3时(部分工作):
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^info\.oldsite\.co\.uk [NC]
RewriteRule ^(.*)$ https://info.new.com/blog/$1 [L,R=301,NC]
这里https://info.oldsite.co.uk/dsadasdsad会变成https://info.new.com.co.uk/%60https://info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/%60https:/info.new.com.com/blog/blog/fsdfdsfsd%60%60%60%60%60%60%60%60%60%60%60%60%60%60%60%60%60%60%60
AND https://info.oldsite.co.uk/blog/dsadasdsad将转到https://info.new.com.com//blog/dsadasdsad(几乎可以正常工作,但此处有双斜杠“//”)
1条答案
按热度按时间au9on6nz1#
因此,
info.oldsite.co.uk/blog/xyzxyz
会变成info.new.com/blog/xyzxyz