How to remove .php, .html extension from URL

This tutorial I’ll show you to remove .PHP extension from browser URL. This will help you to boost your website SEO ranking. inside the project root directory create .htaccess file

Create .htaccess file

<code data-enlighter-language="apache" class="EnlighterJSRAW">RewriteEngine On
RewriteRule ^([^/]+)$ index.php?id=$1 [L,QSA]

If you can check your browser without adding .php extension this will be work like

Now, if you want to remove .html extension from URL do the same thing just add one line extra

<code data-enlighter-language="apache" class="EnlighterJSRAW">RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html [NC,L]

Leave a Reply