Redirect index.html and index.php to Homepage of a website with .htaccess

Rate this post
Recently, I have an SEO site having two major issues :

  1. Without www site domain was not forwarded to www
  2. When I hit on Home page, it opened with /index.html extension
Although i have created a post for how to redirect non www domain to www and vice versa. so you can fixed problem number 1. where as for number 2 issue(/index.html extension problem), i will give you a code which you need to put in .htaccess file and upload it into the domain root. where as you can use canonical tag also which will help Google to know the original page but to remove this issue completely from your website you need to read this post.

Note : If you already have a .htaccess file uploaded to the server, just edit that and paste the below code  after the code present so that both the issues will be resolved through a single .htaccess file. If there is no .htaccess file just make a fresh file.

Also See : Learn how to resolve  301 error in a website (redirect non www to www)
Redirect Single Page to another page in a Website

If you don’t know how to create a .htaccess file please see this video. (Take help from this video only to know the process to create .htaccess file)

.htaccess code to for redirection of domain/index.html to Homepage.

Please paste the below code in the .htaccess file and upload through ftp in the same path where index page is present.
### re-direct index.html to root / ###RewriteCond %{THE_REQUEST} ^.*/index.html HTTP/
RewriteRule ^(.*)
index.html$ /$1 [R=301,L]

Note : if the pages of website open with .php or .htm extension you just need to replace  .html with .php or .html.


Leave a Reply

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