I have one rewrite rule that sends all requests to index.php
:
RewriteRule ^.*$ index.php [NC,L]
(Apart from RewriteEngine On
, that's all there is in the .htaccess
file)
It works, unless the request path starts with index/
, in which case the result is an 404 Not Found
.
If I change the filename of index.php
to index2.php
(and the rewrite rule to match it), it starts working again, so clearly there's a conflict when the first segment of the requested path equals the first segment of the destination file.
The mod_rewrite
log contains this (when requesting /index/hello
, which fails):
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]
(Some log info stripped out or modified for readability.)
My server is Apache/2.2.22
.
NB: This website, .htaccess
file and index.php
file included, has worked without problems until I reinstalled Debian on a new server, so I'm assuming there's some kind of config conflict or version bug that makes it happen now. I did not change any website files.
Any ideas?