Reputation: 8526
I have the following mod_rewrite directives in a .htaccess file, so that URLs like http://example.com/foo/bar/baz are internally rewritten to index.php?page=baz
RewriteEngine on
RewriteBase /foo/bar/
RewriteRule ^index.php - [L,NC]
RewriteRule ^([^/]*)/?$ index.php?&p=$1 [L,QSA]
RewriteRule ^([^/]*)/([^/]*)/?$ index.php?&p=$1&v=$2 [L,QSA]
It works fine at
and anything else I've thrown at it, except if the first parameter is index.
I've turned RewriteLogLevel up to 9, and I get entries like this one when I visit http://example.com/foo/bar/index/baz
[perdir ..../foo/bar/] add path info postfix: ..../foo/bar/index.php -> ..../foo/bar/index.php/baz
So it looks like something internal to apache is actually rewriting the /index/ part of the URL to /index.php/ before mod_rewrite even sees it, which is a bit of a problem. It isn't rewriting anything else incorrectly, just index.
I really don't understand why it won't work with index but will with everything else. These are the only rewrite directives for this project, and it's a stock setup otherwise.
This is Apache 2.2.21 and PHP 5.3.8.
I hope I'm being clear, but just in case, I want URLs rewritten like this:
It all works fine, except for URLs with index.
Upvotes: 0
Views: 90
Reputation: 16825
Try adding Options -MultiViews
to your htaccess, to prevent the clash with index.php
Upvotes: 1