Remove .php and .html extension from URL using .htaccess

To remove .php and .html extension from URL. In This article i am show you how to remove.

First create .htacess file and write below code

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

Save file into .htaccess and put into your project root directory. for example xampp server inside htdocs suppose your website name demo, put  .htaccess file inside demo directory.

 

Leave a Reply

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