1

我已经查看了 SO 并想出了这段代码,我认为它应该可以工作,但它没有:

RewriteEngine On
RewriteRule favicon.png - [NC]
RewriteRule robots.txt - [NC]
RewriteRule sitemap.xml - [NC]
RewriteRule ^static - [L,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

基本上所有内容都应该重写,除了: favicon.png robots.txt 目录“静态”中的所有内容

它的一部分有效。favicon.png 返回 favicon.png 文件,而不是重写为 index.php。“静态”内部的内容也不会被重写。但是 robots.txt 和 sitemap.xml 不起作用。我不知道为什么。任何人都可以帮忙吗?

4

1 回答 1

1

您可以将所有这些组合成一个更正确的规则。试试这个代码:

RewriteCond %{REQUEST_URI} !^/(favicon\.png|robots\.txt|sitemap\.xml|static/) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
于 2013-10-06T10:09:14.737 回答