Reputation: 618
I'm trying to use a htaccess rewrite rule like this:
IF url =
http://example.com/admin/dashboard
LOAD FILEhttp://example.come/admin/dashboard.php
I have this file structure
example.com/
|-- admin/
|-- .htaccess
|-- dashboard.php
if I write this in my .htaccess file
RewriteEngine On
RewriteRule ^test$ dashboard.php
and type this address on my browser http://example.com/admin/test
I correctly see the content of dashboard.php file
But if I change my .htaccess file to
RewriteEngine On
RewriteRule ^dashboard$ dashboard.php
and type http://example.com/admin/dashboard
in by browser I get a Not Found page
why RewriteRule works only if my url point to a non-existing file?
Upvotes: 1
Views: 120
Reputation: 785541
Turn off MultiViews
option in your .htaccess which might have been turned on in your server config.
Options -MultiViews
RewriteEngine On
RewriteRule ^dashboard/?$ dashboard.php [L,NC]
You may also add RewriteBase
just below RewriteEngine
line:
RewriteBase /admin/
Upvotes: 0