Jump to content

Disallow Browser Code


phillipw1994

Recommended Posts

<?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

Link to comment
https://forums.phpfreaks.com/topic/245412-disallow-browser-code/
Share on other sites

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;
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.