Solved

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

Posted on 2016-08-08
4
70 Views
Last Modified: 2016-08-08
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
0
Comment
Question by:boltweb
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
James Bilous earned 500 total points
ID: 41747397
Perhaps something like the following:

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

Open in new window

0
 
LVL 7

Expert Comment

by:Swatantra Bhargava
ID: 41747455
try below code :

RewriteEngine On
RewriteBase /

# redirect html pages to the root domain
RewriteRule ^index\.html$ / [NC,R,L]
1
 

Author Closing Comment

by:boltweb
ID: 41747503
Thank you. It worked perfectly.
0
 

Author Comment

by:boltweb
ID: 41747507
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

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Apache / XAMPP  authorisation 10 45
FTP File permissions 1 45
Set cookies HttpOnly and Secure 4 108
REReplaceNoCase help 1 13
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now