Apache url rewrite – removing .php extension via .htaccess

Add to the .htaccess (make sure the vhost can read htaccess files)

# Avoid listing files, enable multiviews
Options -Indexes -MultiViews
# Enable RewriteEngine
RewriteEngine On
# Don’t rewrite directory names
RewriteCond %{REQUEST_FILENAME} !-d
# Don’t rewrite file names
RewriteCond %{REQUEST_FILENAME} !-f
# Remove .php extension
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading Facebook Comments ...
Loading Disqus Comments ...