在根中,代码已经在工作(例如(:
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
以及https://info.oldsite.co.uk/blog/dsadasdsad将https://info.new.com.com//blog/dsadasdsad(几乎可以工作,但这里是双斜线"//"(
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^info.oldsite.co.uk [NC]
RewriteRule ^(.*)$ https://info.new.com%1/$1 [L,R=301,NC]
因此,info.oldsite.co.uk/blog/xyzxyz
将转到info.new.com/blog/xyzxyz