2

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?

1 Answer 1

2

Add this:

Options -Multiviews

they usually don't play very nice in combination with mod_rewrite

BTW: if that's all you do currently, using the new-ish FallbackResource might be more efficient. (Version >= 2.2.16).

1
  • @wrikkwn, Thank you, I added Options -Multiviews directly to the top of my .htacces file and it immediately started working again! I would have liked to solve things in a more elegant way, as you suggest, but it's not my own repository, so I'll just stick with this solution.
    – jgivoni
    Feb 12, 2014 at 8:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .