Redirect index.php to root (/)

Last Updated: Feb. 17th 2022 at 6:21pm Tags: apache blog htaccess

How to redirect all traffic to a single page.

One page sites are really popular.
If you have a one page static html (or php) site, this article explains how to redirect your index.php or index.html to just

If you use a CMS or frame work this is usually already done for you, so you don’t have to worry; however, if a simple (usually static) page at can be redirected to

Remove index.html from url htaccess

Put this in your .htaccess file at the same level as your index.html file.

#change this to index.html if necessary
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
#update the domain name below and update the .php to .html if nessisary
RewriteRule ^index\.php$ [R=301,L]

Be sure to change the index.php to index.html (if required) and the domain name as well.

Some people say that this will remove duplicate content from search engines, but I’m pretty sure search engines are smart enough to figure this out themselfs.



You need to login to comment.