Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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).

share|improve this answer
    
@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 at 8:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.