Remove .php extension from URL using htaccess

Hi friends, You might wonder seeing some sites will not display any .php extension even though they developed the website using normal php script.

This can be achieved using htaccess. It’s damn simple and here is the code:

The below script will change your url from:

to       :

Save the below script as (.htaccess) and upload it in your root folder or the folder you keep all your files (also work in sub-folder too!)

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

NOTE: Better download notepad++ to save this file as .htaccess, because default notepad won’t allow it!

For your convenience I put a demo here you can check in both the ways:

with extension:

without extension:

I had put this code in the sub-folder (demo) of my site!

For your better convenience I have given the Download too!


About the Author


Software Engineer, Blogger etc., Visit my Youtube channel - <a href="">Click Here</a>

5 thoughts on “Remove .php extension from URL using htaccess

Leave a Reply

Your email address will not be published. Required fields are marked *