Wednesday, May 2, 2018

How to remove file extensions from display via htaccess?

Create a file with the name of .htaccess and save that file in root folder of your website with following lines to use the .html and .php pages without extension.

Extension also work if provided but now we don't need the extension.

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


No comments:

Post a Comment