.htaccess rewrite rule to 301 redirect canonical versions of homepage to root

We have an apache webserver and neet to modify the .htaccess file so that all possible canonical versions of our homepage redirect to the root of domain without the trailing slash i.e. we want the homepage to have this URL:   http://www.our-website.com   

We setup some .htaccess redirects which deal most of the canonicals however when we found that we also need to redirect http://www.our-website.com/index.html  TO root  http://www.our-site.com  

 What would be the additional rewrite rule we need to add to the ones we have already  to do this?

This is what we have so far in our .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^our-website.com
RewriteRule (.*) http://www.our-website.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^[0-9]+(\.[0-9]+){3} [OR]
RewriteCond %{HTTP_HOST} ^our-website\.com
RewriteRule (.*) http://www.our-website.com/$1 [R=301,L]
rewritecond %{HTTP_HOST} ^our-website\.com
rewriteRule ^(.*) http://www.our-website.com/$1 [R=301,L]


Thank you
LVL 1
boltwebAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
James BilousConnect With a Mentor Software EngineerCommented:
Perhaps something like the following:

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

Open in new window

0
 
Swatantra BhargavaTeam LeaderCommented:
try below code :

RewriteEngine On
RewriteBase /

# redirect html pages to the root domain
RewriteRule ^index\.html$ / [NC,R,L]
1
 
boltwebAuthor Commented:
Thank you. It worked perfectly.
0
 
boltwebAuthor Commented:
Thank you for your reply. I had already implemented the first solution so I do not yet know if your solution would have worked.  I just wanted to say thank you anyway.
0
All Courses

From novice to tech pro — start learning today.