phillipw1994 Posted August 22, 2011 Share Posted August 22, 2011 <?php if (eregi("MSIE",getenv("HTTP_USER_AGENT")) || eregi("Internet Explorer",getenv("HTTP_USER_AGENT"))) { Header("Location: http://mysite.com/ie_reject.html"); exit; } ?> How would i make users who are using Safari get redirected like in this example would i use this <?php if (eregi("SAFARI",getenv("HTTP_USER_AGENT")) || eregi("Safari",getenv("HTTP_USER_AGENT"))) { Header("Location: http://mysite.com/safari_reject.html"); exit; } ?> If so how would i add these together in one statement to stop both accessing my site and get redirected Quote Link to comment https://forums.phpfreaks.com/topic/245412-disallow-browser-code/ Share on other sites More sharing options...
theverychap Posted August 22, 2011 Share Posted August 22, 2011 Seeing as you are using eregi - you do not need to test for lowercase AND uppercase - the i in eregi is case insensetive, and so will pick up all cases... However, eregi is depreceated, so maybe you should use preg_match, or even stristr would do: if ( stristr($_SERVER['HTTP_USER_AGENT'], 'safari') ) { header('location: http://...'); exit; } Quote Link to comment https://forums.phpfreaks.com/topic/245412-disallow-browser-code/#findComment-1260437 Share on other sites More sharing options...
ignace Posted August 22, 2011 Share Posted August 22, 2011 Or use the Browser class. $browser = new Browser(); switch ($browser->getBrowser()) { case Browser::BROWSER_SAFARI: /* safari browser */ break; } Quote Link to comment https://forums.phpfreaks.com/topic/245412-disallow-browser-code/#findComment-1260446 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.