
When we create a website using html or php. then we need the page extension like index.html, about.html and after also that we create index.php what shows after the page name.
We are going to learn how to remove page extension using small code.
First > Create .htaccess file
copy this code and paste in .htaccess file (If extension is html)
------------------------------------------------------------------------------------------------
RewriteEngine on RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC] RewriteRule ^ /%1 [NC,L,R] RewriteCond %{REQUEST_FILENAME}.html -fRewriteRule ^ %{REQUEST_URI}.html [NC,L]
-------------------------------------------------------------------------------------------------------
if extension is php then
===========Remove PHP Extension========= RewriteEngine on RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC] RewriteRule ^ /%1 [NC,L,R] RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^ %{REQUEST_URI}.php [NC,L]
===============Remove PHP Extension==========

Leave a Comment