For Clients
For Geeks

Remove “.php” extension from URL

In: Apache

In order to have nice URLs you could use various techniques. But in case you have a really simple website with pages written in PHP, and URLs pointing to those PHP files like, you could set nice URLs using .htaccess only. Using following snippet will let you have URLs like, and still open your file.

Just use following snippet in order to remove “.php” extension from URL.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/$ $1.php

Written by

Dejan Jacimovic is passionate entrepreneur & software developer with Master's Degree in Computer Science. He likes to share his thoughts on e-commerce business, management and life on StuntCoders magazine and his own blog.

Sell More With Magento & Facebook