I'm using this in my top level .htaccess to remove the PHP file type extension on my *.php files.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
But I have discovered it also prevents my browser from calling the index.php page in my sub-directories. I need to include /index.php explicitly in the URL.
Is there a better way to remove the PHP file type extension on my *.php files?
here you go:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
or try this one. This should also work in a sub-directory path:
RewriteEngine on
RewriteRule ^(.*)$ $1.php
or in an if clause
<IfModule mod_rewrite.c>
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>