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]

Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form. Links to this article are welcome

Other Related Articles