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.
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]
How to remove index.php from URL for all pages.
RewriteRule ^index\.php$ / [R=301,L]
RewriteRule ^(.*)/index\.php$ /$1/ [R=301,L]
Save the file and you're done!
Leave a comment
Your email address will not be published. Required fields are marked *