Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.