我有两个脚本:
- xmlsitemap.php(谷歌XML网站地图(
- sitemap.php(GUI用户友好型网站地图(
我想通过重写规则来实现这一点:
重写到site.com/sitemap.php
site.com/sitemap
site.com/sitemap/
重写到site.com/xmlsitemap.php
site.com/sitemap.xml
这是我试过的。问题是它正在将sitemap.xml重写为sitemap.php(GUI(。
Options +FollowSymlinks
RewriteEngine On
RewriteRule sitemap.xml xmlsitemap.php
RewriteRule sitemap sitemap.php
# also tried using [L] option on both
首先,重新添加[L]
标志。其次,如果一个规则取代了另一个规则,请检查重写规则regex,使它们更好地匹配,就像整个请求一样:
RewriteRule ^sitemap'.xml$ xmlsitemap.php [L]
RewriteRule ^sitemap$ sitemap.php [L]
L
标志将阻止运行已经匹配的附加规则(但仍然可以触发内部重定向,请参阅END标志而不是L标志(。