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

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

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

Read Article
Ork: SSH Server Automation in Go

Ork: SSH Server Automation in Go

Read Article
Deno Deploy Killed My Start Page

Deno Deploy Killed My Start Page

Read Article
View All Blog Posts