我需要编写一个重写规则来从一个域重定向到另一个域。
maindomain.com/en/ -> secounddomain.com/en/
maindomain.com/en/pagename.html -> secounddomain.com/en/pagename.html
www.maindomain.com/en/ -> secounddomain.com/en/
www.maindomain.com/en/pagename.html -> secounddomain.com/en/pagename.html
secounddomain.com -> secounddomain.com/en/
www.secounddomain.com -> secounddomain.com/en/
并且为了安全(没有背部)
secounddomain.com/pl/ -> secounddomain.com/en/
www.secounddomain.com/pl/ -> secounddomain.com/en/
我尝试这样做,但它不起作用:
RewriteCond %{HTTP_HOST} ^maindomain.com/en/$ [NC]
RewriteRule ^(.*)$ http://www.secounddomain.com/en/$1 [r=301,L]
RewriteCond %{HTTP_HOST} ^www.maindomain.com/en/$ [NC]
RewriteRule ^(.*)$ http://www.secounddomain.com/en/$1 [r=301,L]
RewriteCond %{HTTP_HOST} ^www.secounddomain.com/pl/$ [NC]
RewriteRule ^(.*)$ http://www.secounddomain.com/en/$1 [r=301,L]
RewriteCond %{HTTP_HOST} ^secounddomain.com/pl/$ [NC]
RewriteRule ^(.*)$ http://www.secounddomain.com/en/$1 [r=301,L]
此致。