Blog

Remove PHP Extension

Here is how to remove the PHP extension from files and call a 404 errors handler if the URI is not found

Options +FollowSymLinks -MultiViews

DirectoryIndex index.html index.php

RewriteEngine On
RewriteBase /

# Hide PHP extension
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]

# 404 Not Found (Notify)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /errors.php [L]