Reputation:
My hosting is from namecheap and I use the following code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
I get 404 error when I try to access a php file without extension. I know it was discussed many times but the solutions here from stackoverflow are not working for me.
Upvotes: 2
Views: 340
Reputation: 7662
Try
Options +MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^(.+)\.php$ /$1 [R,L]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ /$1.php [NC,END]
Note: Above solution is for Apache version 2.4 and above as END flag isn't supported by older versions.
Upvotes: 1