SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect visitors using Internet Explorer

    Hello My friends,

    I know you are passing a nice holiday with your family and friends, so permit me to bother you with my question: How can I redirect visitors using Internet Explorer to a page web ? I hope it is possible to do it with htaccess, in the goal to redirect ALL visitors who visit any page on the website.

    In fact, I have installed a wordpress website to a friend, and it works perfect on all the web browsers, but unfortunately not on Internet Explorer. The user should go to TOOLS option on IE, and change the navigation type from Quirks to Internet Explorer 9 to be able view the website properly.

    Best regards to you all, and thanks in advance for your help!

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,890
    Mentioned
    211 Post(s)
    Tagged
    12 Thread(s)
    Hi there,

    There are many different things that can cause Quirks Mode, for example, having stuff before the doctype.
    As a quick fix, try adding this to the head section of your document:

    HTML Code:
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    If this doesn't help, would it be possible for you to post a link to the site with a short description of the problem?

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Um. the solution is to fix your web pages not to force IE users to fix your problem for you. If IE9 is going into quirks mode you have invalid code, invalid HTML, fix it.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Addict bbparis's Avatar
    Join Date
    Aug 2008
    Posts
    323
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you guys for your help, I will try to fix it with Pullo's solution, and get back to you. Regards!

  5. #5
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,890
    Mentioned
    211 Post(s)
    Tagged
    12 Thread(s)
    Hi there, something like this should work:

    Code PHP:
    <?
    if ( preg_match("/MSIE/",$_SERVER['HTTP_USER_AGENT']) )
      header("Location: indexIE.html");
    else
      header("Location: indexNonIE.html");
    exit;
    ?>

    There's a good discussion of this here: http://stackoverflow.com/questions/7...-to-a-new-page

  6. #6
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Pullo View Post
    Hi there,

    There are many different things that can cause Quirks Mode, for example, having stuff before the doctype.
    As a quick fix, try adding this to the head section of your document:

    HTML Code:
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    If this doesn't help, would it be possible for you to post a link to the site with a short description of the problem?
    I put that edge line in my site a while back to text and it still kept going into quirks mode

  7. #7
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Johanthaontarott View Post
    I was wondering if anyone knows a nice PhP script that will redirect users to another page if they are on ANY Internet Explorer client? I've found;
    PHP Code:
    <!--[if IE 6]>
    <meta http-equiv="refresh" content="0;http://www.mysite.com/iesplash/">
    <![endif]-->
    Number 6 http://www.visibilityinherit.com/code/target-ie.php

  8. #8
    SitePoint Member
    Join Date
    Jun 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bbparis: Did including the meta element fix your web site in IE? If not, you may want to look at makingsure you're using an HTML5 doctype: <!DOCTYPE html>. This will force later versions of IE into standards mode.

    I want to reiterate that it is a very bad idea to force all versions of IE to redirect to a different page. While earlier versions of IE were behind the times due to a 5 year leave of absence, IE9, and especially IE10 are modern browsers. They should render your content as expected if you're following standards. They shouldn't require any extra effort to support on your part than other modern browsers. Redirecting all users of current and future versions of IE just harms the users that choose to use those browsers.

  9. #9
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,788
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Pullo View Post
    Hi there, something like this should work:

    Code PHP:
    <?
    if ( preg_match("/MSIE/",$_SERVER['HTTP_USER_AGENT']) )
      header("Location: indexIE.html");
    else
      header("Location: indexNonIE.html");
    exit;
    ?>
    That would redirect anyone who has Firefox, Chrome, Safari or Opera set with a useragent containing MSIE to indexIE.html even though the browser is not Internet Explorer. All browsers can use a useragent that identifies them as Internet Explorer and many people have whatever browser they are using set that way to bypass all the stupid browser testing scripts in antiquated web pages that only allow you to visit the page using Internet Explorer.

    Also it would not send anyone using Internet Explorer who has their useragent set to not contain MSIE to the indexNonIE.html page - Internet Explorer allows you to set the useragent to anything at all. It's a good place to advertise where your ad is unlikely to be blocked.

    The only way to properly identify Internet Explorer is by using conditional comments either in HTML or in JScript - it can't be done on the server.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  10. #10
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,890
    Mentioned
    211 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by felgall View Post
    The only way to properly identify Internet Explorer is by using conditional comments either in HTML or in JScript - it can't be done on the server.
    Yup, browser sniffing sucks, which brings us nicely back to @logic_earth ;'s point, that it would be better to fix the site in the first place.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •