Jump to content

iPhone and other devices redirect


asterix222

Recommended Posts

Hi everybody

 

I want to put this code (or something like that) in my index.php to redirect the iPhones etc.

But where do I have to put it in? In the head or body?? And how can I call this function?

 

Thanks a lot for helping a beginner!

function ismobile(){
$useragent = $_SERVER[‘HTTP_USER_AGENT’];
// Standard vendor-model/version user agents
if(preg_match(‘/^((ACER¦Alcatel¦AUDIOVOX¦BlackBerry¦CDM¦Ericsson¦LG\b¦LGE¦Motorola¦MOT¦NEC¦Nokia¦Panasonic¦QCI¦SAGEM¦SAMSUNG¦SEC¦Sanyo¦Sendo¦SHARP¦SIE¦SonyEricsson¦Telit¦Telit_mobile_Terminals¦TSM)[- ]?([^\/\s\_]+))(\/(\S+))?/’, $useragent)){
return true;
}else{
return false;
}
}

Link to comment
Share on other sites

Technically I think one would want to use JS for this kind of thing, but you could try this:

 

 

   if (stripos($_SERVER['HTTP_USER_AGENT'], 'iPhone') ===false &&
      stripos($_SERVER['HTTP_USER_AGENT'], 'Android') === false &&
      stripos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') ===false)

    {
        // go to non-mobile page using header call
       header("Location: desktophome.php");
       exit();
    }
   else
   {
      //   go to Mobile page instead
      header('Location:  mobilehome.php");
       exit();
   |
Link to comment
Share on other sites

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.