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 using .htaccess.

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]
← Previous
Tools
Next →
End of 2016 - VPS Hosting Prices

Keep Reading

Explore more articles and insights

uid: SafeShortID and HexShortID — Time-Ordered IDs Without the Rude Words

uid: SafeShortID and HexShortID — Time-Ordered IDs Without the Rude Words

Read Article
Bootlegance: 70 Free Bootstrap 5 Themes with Native Dark Mode

Bootlegance: 70 Free Bootstrap 5 Themes with Native Dark Mode

Read Article
A Big, Opinionated List of PHP Libraries (2026 Edition)

A Big, Opinionated List of PHP Libraries (2026 Edition)

Read Article
View All Blog Posts