Solved

htaccess redirect

Posted on 2014-03-10
5
395 Views
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 newsite.com  to the same page within oldsite.com ?
0
Comment
Question by:ddantes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 58

Accepted Solution

by:
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">
      currUrl=document.URL
      window.location = currUrl.replace("newsite.com","oldsite.com"); 
</script>
<![endif]--> 

Open in new window

0
 
LVL 23

Expert Comment

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


FYI,  I grabbed this here,
stackoverflow.com/questions/12666684/redirect-ie-6-7-and-8-users-with-htaccess
0
 

Author Comment

by:ddantes
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.
0
 
LVL 58

Expert Comment

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

Open in new window


May need to double check this as I cannot test.
0
 

Author Comment

by:ddantes
ID: 39918451
This did it:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "MSIE [6-8]" [NC]
RewriteCond %{HTTP_HOST} ^www\.mauivacationrental\.com$
RewriteRule (.*) http://www.mauitradewinds.com/$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.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

726 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