Redirect URL for Apple iPad, ipod, iphone, Android, Opera Mini, Blackberry, Palm, Windows Smartphone !

phpSometimes we want to improve our websites  so it can be accessed on any platform of devices like iPad, Blackberry, ipod, etc.  Then we develop the main website that can be accessed on any desktop,notebook/netbook.  Then we also create the Mobile website versions so it can be accessed on iphone, blackberry or windows smartphone.

thanks for http://detectmobilebrowsers.mobi/ that provides some functions to redirect websites on any devices you have.

they provide one simple script in .php to redirect your websites to the URL that you can specify yourself.

you just need to include the files and then running the functions like this :

<?

$redirect = “http://www.metrotvnews.com/mobile-site/”;

require_once(‘mobile_device_detect.php’);
mobile_device_detect(true,true,true,true,true,true,true,$redirect,true);

?>

or

<?

require_once('mobile_device_detect.php');
mobile_device_detect(true,false,true,true,true,true,true,'http://www.metrotvnews.com/mobile-site',false);

?>

that 2 scripts above will checking if  HTTP_USER_AGENT (get the user agent value)  are coming from blackberry devices then it will be redirect to the mobile site at http://www.metrotvnews.com/mobile-site/

notes : mobile_device_detect(true,true,true,true,true,true,true,true,true);

The function has 9 parameters that can be passed to it which define the way it handles different scenarios. These paramaters are:

  • iPhone – Set to true to treat iPhones as mobiles, false to treat them like full browsers or set a URL (including http://) to redirect iPhones and iPods to.
  • iPad – Set to true to treat iPads as mobiles, false to treat them like full browsers or set a URL (including http://) to redirect iPads to.
  • Android – Set to true to treat Android handsets as mobiles, false to treat them like full browsers or set a URL (including http://) to redirect Android and Google mobile users to.
  • Opera Mini – Set to true to treat Opera Mini like a mobile, false to treat it like full browser or set a URL (including http://) to redirect Opera Mini users to.
  • Blackberry – Set to true to treat Blackberry like a mobile, false to treat it like full browser or set a URL (including http://) to redirect Blackberry users to.
  • Palm – Set to true to treat Palm OS like a mobile, false to treat it like full browser or set a URL (including http://) to redirect Palm OS users to.
  • Windows – Set to true to treat Windows Mobiles like a mobile, false to treat it like full browser or set a URL (including http://) to redirect Windows Mobile users to.
  • Mobile Redirect URL – This should be full web address (including http://) of the site (or page) you want to send mobile visitors to. Leaving this blank will make the script return true when it detects a mobile.
  • Desktop Redirect URL – This should be full web address (including http://) of the site (or page) you want to send non-mobile visitors to. Leaving this blank will make the script return false when it fails to detect a mobile.

You can also generate the functions from their websites and tuning the scripts according to your needs.

thanks

~Rio Yotto Uniwaly

 

Leave a Reply

Your email address will not be published. Required fields are marked *