Hiding .php extensions in your urls

Hi readers,

I am building a website from a platform that utilizies the page extensions. I found some code on the internet that enabled me to hide the .php extensions but I am having problems now on the server side (with the .htaccess file uploaded) that when I go to the page I’m looking for it picks the folder name instead.

As some as my page names are the same as my folder names, I want to be able to tell the server to go to the file and not the folder. This works without the .htaccess file code below so it needs a little tweaking I presume.

The code I am currently using is:

If anyone out there can help me I would really appreciate it!!

The website is a redesign of the joomla platform which has been indexed for a long time in Google so changing the page or folder names and adding redirects I am trying to do without.

RewriteEngine On
RewriteBase /

remove enter code here.php; use THE_REQUEST to prevent infinite loops

RewriteCond %{THE_REQUEST} ^GET\ (.).php\ HTTP
RewriteRule (.
).php$ $1 [R=301]

remove index

RewriteRule (.*)/index$ $1/ [R=301]

add .php to access file, but don’t redirect

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1.php [L]

Sponsor our Newsletter | Privacy Policy | Terms of Service