Support Me

Search

How to remove .html and .php from the address bar.

How to remove .html and .php from the address bar.

oday I will tell you how to remove .html and index.php from the address bar using .htaccess. To make the site address beautiful, you can remove it both for the main page and for all pages.

First. Open the .htaccess file in the site's root directory. In the absence of such a file, you must contact the hosting administration, or create it. Don't forget it starts with a dot.

Second. Add to the .htaccess file one of the following rules that you need.

How to remove index.html from home page url.

RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]



How to remove index.php from home page url.

RewriteEngine On
RewriteRule ^index\.php$ / [R=301,L]



How to remove index.html from URL for all pages.

RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]



How to remove index.php from URL for all pages.

RewriteEngine On
RewriteRule ^index\.php$ / [R=301,L]
RewriteRule ^(.*)/index\.php$ /$1/ [R=301,L]



Save the file and you're done!

Rehmatullah Mallah

Rehmatullah Mallah

Photographer - Videographer - Web Designer

Leave a comment

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

Your experience on this site will be improved by allowing cookies Cookie Policy