I have two scripts:
我有两个脚本:
- xmlsitemap.php (Google XML sitemap)
- xmlsitemap.php(Google XML站点地图)
- sitemap.php (GUI user friendly sitemap)
- sitemap.php(GUI用户友好的站点地图)
I want to achieve this with rewrite rules:
我想用重写规则来实现这个目标:
Rewrite to site.com/sitemap.php
site.com/sitemap
site.com/sitemap/
重写到site.com/sitemap.php site.com/sitemap site.com/sitemap/
Rewrite to site.com/xmlsitemap.php
site.com/sitemap.xml
重写到site.com/xmlsitemap.php site.com/sitemap.xml
Here is what I have tried. The problem is it's rewriting sitemap.xml to sitemap.php (GUI).
这是我尝试过的。问题是它将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
1 个解决方案
#1
7
First of all, re-add the [L]
flag. Second, if one rule supersedes the other, check your rewrite rules regex to make them better matching, like the whole request:
首先,重新添加[L]标志。其次,如果一条规则取代另一条规则,请检查重写规则正则表达式,使它们更好地匹配,就像整个请求一样:
RewriteRule ^sitemap\.xml$ xmlsitemap.php [L]
RewriteRule ^sitemap$ sitemap.php [L]
The L
flag will prevent to run additional rules if one already matched (but still can trigger an internal redirect, see as well the END flag instead of the L flag).
如果已经匹配(但仍然可以触发内部重定向,也可以查看END标志而不是L标志),L标志将阻止运行其他规则。
#1
7
First of all, re-add the [L]
flag. Second, if one rule supersedes the other, check your rewrite rules regex to make them better matching, like the whole request:
首先,重新添加[L]标志。其次,如果一条规则取代另一条规则,请检查重写规则正则表达式,使它们更好地匹配,就像整个请求一样:
RewriteRule ^sitemap\.xml$ xmlsitemap.php [L]
RewriteRule ^sitemap$ sitemap.php [L]
The L
flag will prevent to run additional rules if one already matched (but still can trigger an internal redirect, see as well the END flag instead of the L flag).
如果已经匹配(但仍然可以触发内部重定向,也可以查看END标志而不是L标志),L标志将阻止运行其他规则。