htaccess redirect

Posted on 2014-03-10
Last Modified: 2014-03-10
I have a new website based on html5.  I would like visitors whose browsers are lte IE8 to be redirected to my previous site, which doesn't use html5.  I tried javascript in the <HEAD> section of the dynamic template, but that always directs requests for any page in the new site to the index page of the old site, instead of the comparable page.  Can you supply .htaccess code which will replace requests for any page within  to the same page within ?
Question by:ddantes
  • 2
  • 2
LVL 58

Accepted Solution

Gary earned 250 total points
ID: 39918338
Just make a bit of a change to the old code

<!--[if lt IE 8]>
<script type="text/javascript">
      window.location = currUrl.replace("",""); 

Open in new window

LVL 23

Expert Comment

ID: 39918340
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "MSIE [6-8]" [NC]
RewriteRule ^(.*)$ [R=301,L]

FYI,  I grabbed this here,

Author Comment

ID: 39918374
Thank you both.  I'd prefer to use .htaccess, since it avoids the necessity of placing code on every page.  However, the .htaccess code above didn't work.  If I include the suffix "/ie" there is a 404 error.  If I omit that suffix, the redirect goes to the index page, instead of the specific page in the old site.  If this can't be corrected, I'll be happy to use Gary's javascript.
LVL 58

Expert Comment

ID: 39918402
RewriteEngine on 
RewriteCond %{HTTP_HOST} !^newsite\.com$
RewriteCond %{HTTP_USER_AGENT} "MSIE [6-8]" [NC]
RewriteRule ^(.*)$$1 [R=301,L]

Open in new window

May need to double check this as I cannot test.

Author Comment

ID: 39918451
This did it:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "MSIE [6-8]" [NC]
RewriteCond %{HTTP_HOST} ^www\.mauivacationrental\.com$
RewriteRule (.*)$1 [L,R=301]

Thanks again to you both.  I'm accepting the earlier javascript solution, which gives me a good alternative, even though I'm implementing the .htaccess approach.

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
phpmyadmin installation 3 62
Webmin Bandwidth Monitoring not working 10 130
file path 14 69
How can I write .htaccess code to redirect 301 pages? 1 122
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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