我有一个重写规则,将所有请求发送到index.php :
RewriteRule ^.*$ index.php [NC,L]
(除了RewriteEngine On ,这就是.htaccess文件中的所有内容)
它工作,除非请求path以index/开头,在这种情况下,结果是404 Not Found 。
如果我将index.php的文件名更改为index2.php (并重写规则以匹配它),它将再次开始工作,所以当请求的path的第一个段等于目标文件的第一个段时 , 显然会有冲突 。
mod_rewrite日志包含这个(当请求/index/hello , 失败 ):
add path info postfix: /path/to/index.php -> /path/to/index.php/hello strip per-dir prefix: /path/to/index.php/hello -> index.php/hello applying pattern '^.*$' to uri 'index.php/hello' rewrite 'index.php/hello' -> 'index.php' add per-dir prefix: index.php -> /path/to/index.php initial URL equal rewritten URL: /path/to/index.php [IGNORING REWRITE]
(某些日志信息被删除或修改为可读性。)
我的服务器是Apache/2.2.22 。
注意:这个网站,包括.htaccess文件和index.php文件,直到我在一台新的服务器上重新安装Debian之前,这个工作没有任何问题,所以我假设有某种configuration冲突或版本错误,现在就发生了。 我没有更改任何网站文件。
有任何想法吗?
添加这个:
Options -Multiviews
他们通常不会和mod_rewrite结合起来
顺便说一句:如果这就是你现在所做的一切,那么使用new-ish FallbackResource可能会更有效率。 (版本> = 2.2.16)。