• $useragent=$_SERVER[‘HTTP_USER_AGENT’];
    if(preg_match(‘/iphone|ipod|android/i’,$useragent))
    header(‘Location: https://mysite.com/mobile/’);

    I have put this text above everything else in the header and also in the functions file on some WP installs and it works great, but then in this one it won’t work at all. the site is hotelandra.com

    I really need this to work… any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter tjsherrill

    (@tjsherrill)

    Ok so I figured it out. I have a caching plugin setup and it was keeping the mobile redirect from happening.

    Is there a way to do caching and still have this redirect work?

    I am using Quick Cache by PrimoThemes

    Thread Starter tjsherrill

    (@tjsherrill)

    Ok I am back, This code works much of the time but it randomly decides not to work. Is this code compatible with WordPress?

    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Useragent redirection not working in functions.php or header’ is closed to new replies.