RewriteRule 仅适用于主页
RewriteRule only works for home page
我有这个 RewriteRule,它创建了从 example1.com 到 example2.com
的永久重定向
在 example1.com 的 htaccess 中,我有这些规则:
#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ https://www.example2.com/ [R=301,L]
重定向适用于 https://www.example1.com/ (it gets redirected to https://www.example2.com). But it does not work for https://www.example1.com/about-us
我希望https://www.example1.com/about-us to be redirected to https://www.example2.com/about-us
将您的重写改成这个:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example1\.com [NC]
RewriteRule (.*) https://www.example2.com/ [R=301,L]
我有这个 RewriteRule,它创建了从 example1.com 到 example2.com
的永久重定向在 example1.com 的 htaccess 中,我有这些规则:
#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ https://www.example2.com/ [R=301,L]
重定向适用于 https://www.example1.com/ (it gets redirected to https://www.example2.com). But it does not work for https://www.example1.com/about-us
我希望https://www.example1.com/about-us to be redirected to https://www.example2.com/about-us
将您的重写改成这个:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example1\.com [NC]
RewriteRule (.*) https://www.example2.com/ [R=301,L]