Dj Techblog

A blog on web development

Redirect default index.html to root- SEO Basics

Last modified on March 8, 2021
Redirect default index.html to root- SEO Basics

In a url the string that follows after http:// or https:// is known as domain name. When we type the domain name of a website, it opens the default home page of the website. The homepage is the default page having file name index.html or index.php depending upon our requirement. That is, when we type domain name of the website, the web server automatically serves the index.html or index.php file.

It doesn’t matter we type or, the webserver serves the same file that is the file whose name start with index.* (where * can be html, php or asp etc.)

This is absolutely fine for the website. But it creates some problem to search engines. So, why should we worry about search engines? Because SEO is an important aspect of website development these days. A problem for search engine will seriously impact the SEO.

So, why redirect default index.html to root?

Search engines are web crawlers which continuously crawls the web and indexes whatever new webpage it finds on its way. It maintains a directory onto which it indexes the url of the webpages. If a webpage is accessible via more than one url, the crawlers gets confused which url to index into the directory for found the webpage. Because the search engines can’t index both the url and waste its space. In simple words we should not have any webpage in our website accessed via two different urls. We should have exactly one url for every page of the website. So, this is necessary that default index.html should always redirect to root.

Our target is now to redirect all the url which ends with index.* to / . Say, if someone types, it should automatically redirect to This way we always have only one version of url for any webpage and not only home page. If we have a webpage in a directory say, it should also redirect to

To implement this we use server’s htaccess file. This is server’s per directory based configuration file. Settings in this file are applicable to all the files and sub-directories below the directory on which the htaccess lies. Lets see how to implement url redirection in htaccess file.

Redirect index.html to root

Below four lines of code will redirect all index.html and index.php to root that is /.

RewriteEngine On

RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteRule ^(.*)index.html$ /$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]

If you like this article, share with your friends. It will inspire me to write more.

Published on March 8, 2021


Debabratta Jena

I mainly write about HTML5, CSS3, Javascript, Angular JS, Ajax, PHP, Mysql, On page SEO, Google Ads, Tag manager, Universal Analytics, Google My Business, SERP, Apache server configuration etc, Yoga is my passion.

Reach to me in the contact us form below

Follow me on

Contact us



Php HTML5 Javascript CSS Ajax Angular JS Google My bisiness Listing Google tag Manager Google Universal Analytics Search Engine Optimization On page SEO Off page SEO Google Marketing platform Digital Marketing Google Ads Mysql Apache Server


Subscribe to get email notification about our new post



We neither sell nor share your personal information with any third party. Your identity is safe with us.