Reputation: 10581
I have the following .htaccess file. It refuses to access the following url structure:
www.example.com/test
Even though it accesses this fine:
www.example.com/test.php
I've ran some more complicated rewrite rules using this file and it worked just fine. For example:
RewriteRule ^tests/([0-9]+)/?$ /tests_page.php?id=$1 [PT,L,QSA]
I don't understand how this can be happening. What am I missing here?
#OPTIONS
Options -Indexes
Options +FollowSymLinks
#ACCESS TO THE .HTACCESS FILE
<Files .htaccess>
order allow,deny
deny from all
</Files>
#REWRITE ENGINE
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteEngine On
#PAGES REWRITE
RewriteRule ^test/?$ /test.php
Update:
I renamed the file to tests.php and changed the rule to this and it worked:
RewriteRule ^test/?$ /tests.php
This still does not explain why this is happening though.
Why can't I have the url folder name match the file name?
Upvotes: 2
Views: 2474
Reputation: 784898
This appears to be a problem with MultiViews
option. Disable it by using:
Options -MultiViews
line at the top of your .htaccess. Option MultiViews
is used by Apache's content negotiation module
that runs before mod_rewrite
module and makes Apache server match extensions of files. So /file
can be in URI but it will serve /file.php
.
Upvotes: 3