I am running Apache 2.2.11
.htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [L,QSA]
The Problem:
http://localhost/index
gives me the Homepage(index.php) properly, but I can also access the same page through the following urls.
http://localhost/index/
http://localhost/index/blahblah
http://localhost/index/blahblah/blah/blah/blah
http://localhost/index.php/
http://localhost/index.php/blahblah/
http://localhost/index.php/blahblah/blah/blah
I want to ensure that only localhost/index will open localhost/index.php, anything other than localhost/index (even localhost/index.php) should return a 404.
I guess I will have to add another RewriteCond
for catching all else but existing Request_Filename.php files. How do I get a 404 for all else but localhost/index?
(This question is on SO too with a bounty, but I guess serverfault might be a better place for it.) Update What does the .htaccess do? The aim of the htaccess files is to enable cleaner urls like localhost/index instead of localhost/index.php more explanation can be found at the source of this code