View Full Version : Remove .php file extension

12-05-2008, 08:36 PM
Hello Everyone,

I am trying to find a way to get clean url with .htaccess;

For example I want http://mysite.com/something not http://mysite.com/something.php

I have this code

Options +FollowSymLinks
RewriteEngine On

# Remove trailing slashes.
# e.g. example.com/foo/ will redirect to example.com/foo
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=permanent,QSA]

# Redirect to PHP if it exists.
# e.g. example.com/foo will display the contents of example.com/foo.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]

It works when I remove the .php myself but I want it to remove it automatically. Instead of me going to the navigation php include and removing the .php to the link. Is that possible?

Thank you. :)

12-09-2008, 01:20 PM
Try this
RewriteRule ^(.*)/$ /$1.php [L] you woud get http://mysite.com/something/ FROM http://mysite.com/something.php

Cheers :)