• Resolved Mickey44

    (@mickey44)


    I’m looking for a way of redirecting Internet Explorer 8 browser users to another site (IE8 is having problems displaying my new site so I want to send all IE8 users to another domain with my old site which displays fine). I’ve got the ‘php-browser-detection’ plugin installed but not sure how to set up a redirect. I know the code for a redirect is something like this:

    <meta http-equiv=”Refresh” content=”0; url=https://domaingoeshere/”>

    And I think the code needs to go in here where ‘do stuff’ is.

    <?php if ( is_lt_IE8() ) { do stuff }; ?>

    I’m not a coder so I may have this totally wrong but if anyone can help that would be great. Thanks.

Viewing 13 replies - 1 through 13 (of 13 total)
  • “meta” redirection isn’t recomended :
    1)because it could break the “back” button functionality
    2) search engines rank your page lower because Meta-redirect is evaluated as ” black hat SEO techniques ” .
    An alternative solution could be :

    // PHP tags are not included
    if ( strpos($_SERVER[‘HTTP_USER_AGENT’], ‘MSIE 8’) )
    {
    header( ‘Location: h ttp://www.tournasdimitrios.host56.com’ ) ;
    }

    I made the test on my development environment and it works .
    Do the test and let me know …

    Thread Starter Mickey44

    (@mickey44)

    Thanks kostas

    Where do I need to enter this code, in the php-browser-detect plugin code or in the code of the main site?

    You have to make sure it’s called before any headers are sent or it’ll crash and burn.

    I would put it in your theme’s functions.php file and hook it to something early, like:

    add_action( 'init', 'redirect_ie' );
    
    function redirect_ie {
        if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) {
            header( 'Location: h ttp://www.example-domain.com' ) ;
        }
    }

    *Note:
    Make sure to take that extra space between the “h” and “t” out. It’s only there to keep this forum from turning that into an actual link.

    Sorry I was not clear with my example .
    Although the example of Big-Bagel could be implemented .
    I suggest a simpler approach , open the header.php file of your theme and paste the code on the absolute top of the file .Don’t forget to include the PHP-tags .
    Let us know if you need help .

    Thread Starter Mickey44

    (@mickey44)

    Thanks guys, I’ll give it a go.

    Thread Starter Mickey44

    (@mickey44)

    I tried entering this at the top of the header code but just got a blank page instead of the homepage:

    <?php
    add_action( 'init', 'redirect_ie' );
    
    function redirect_ie {
        if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) {
            header( 'Location: https://domaingoeshere/' ) ;
        }
    }
    ?>

    If you’re adding it to the top of your header.php file you should just use:

    <?php if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) {
        header( 'Location: h ttp://domaingoeshere/'; ) ;
    } ?>

    and make sure it is literally the very first thing in the file.

    The code I suggested in my earlier post would be if you added it to your functions.php file.

    Thread Starter Mickey44

    (@mickey44)

    It didn’t work, I just get a blank screen instead of the homepage. Also tried adding the earlier code to the functions.php but this totally crashed the site (had to replace the functions.php with a backup to get it to work again).

    Did you copy the code in my last post, because it has an extra “;”

    The right code would be:

    <?php if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) {
        header( 'Location: h ttp://domaingoeshere.com' );
    } ?>

    If you’re getting a blank screen it means php is having a problem. I’ll test it to see if there’s a syntax issue I’m not seeing.

    Thread Starter Mickey44

    (@mickey44)

    I’ll try that and get back to you, thanks man.

    Yup, tested it and it worked fine. Just make sure it’s the first thing in the header.php file and that you replace (h ttp://domaingoeshere.com) with whatever site you want. Also, (this is probably obvious, but I just wanted make sure) be sure to use Internet Explorer 8 to test it. You can change ‘MSIE 8’ to ‘MSIE 9’ or ‘MSIE 7’ if you need to use a different version.

    @mickey44
    Paste the code of your header.php file into Pastebin and post the link here .
    We will make the necessary corrections .

    Thread Starter Mickey44

    (@mickey44)

    Yes, works great, thank you Big Bagel. My new site now works perfectly as before in Safari, Firefox and Chrome and I’ve tested it in IE8 (had to first clear the cache, history etc) and it now redirects to my old site ?? Also thanks to kostas123 for your help.

    Just in case you’re interested the problem I was having with IE8 was displaying PNG files correctly. They display correctly in every other major browser but have rendering problems in IE8. The PNG files display fine in IE9 as they appear to have now sorted the problem.

    Thanks again guys.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Redirect IE8 users to another site’ is closed to new replies.