将域名从ExampleShop.com更改为ExampleStore.com
我在尝试重定向约30个特定页面时遇到问题,并且还对URL映射未仅更改域的页面执行通用重定向。
这就是我所拥有的,它使用通用重写规则重定向所有内容,而不是重定向特定的重写。
Options +FollowSymLinks
RewriteEngine on
#Specialty Rewrites for non-exact mapped URLs
RewriteRule ^/gifts/jewellery/bracelets.html$ http://www.ExampleStore.com/gifts/jewellery/bracelets.html [R=301,L]
RewriteRule ^/gifts/watches/banded.html$ http://www.ExampleStore.com/gifts-for-him/jewellery/watches.html [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#Generic Rewrite for exact mapped URLs
RewriteRule ^(.*)$ http://www.ExampleStore.com/$1 [R=301]
答案 0 :(得分:1)
删除前导斜杠:
RewriteRule ^gifts/jewellery/bracelets.html$ http://www.ExampleStore.com/gifts/jewellery/bracelets.html [R=301,L]
RewriteRule ^gifts/watches/banded.html$ http://www.ExampleStore.com/gifts-for-him/jewellery/watches.html [R=301,L]
.htaccess
是每个目录指令,Apache在RewriteRule
中使用时会从URI中删除前导斜杠。