BlueBird03 BlueBird03 - 1 year ago 120
Apache Configuration Question

Removing .php extensions from files in htdocs

I have my project in my

folder where my main file is
. I have tried multiple time to remove the
extension when the file is opened in the browser, using the
file with the following lines without luck:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L]

The extension remains. Is it because the link in my browser is


and not


Answer Source

You can use:

Options -MultiViews
RewriteEngine on

# remove php
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]

# rewrite with php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+)/?$ $1.php [L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download