PHP Daantje on 26 Oct 2005 09:43 am
mobileBrowserRedirect
I wrote this little PHP script for a friend of mine. He needed to redirect to a xhtml page when a user with a mobile device (internet capable PDA or phone) connected to his homepage. This script is very easy to implement… Just put it at the top of your first index.php file. When a user connects, this script will check the user agent (browser) and when a trigger is present, it will redirect. Hope it helps someone… Have fun.
$redirect = "/2005/xhtml/index.html";
$agents = array(
'Zaurus',
'PDA',
'PalmOS',
'Xda',
'LG',
'MOT-',
'SAMSUNG-SGH-',
'SIE-',
'SonyEricsson',
'SHARP',
'NEC-',
'Panasonic',
'Nokia',
'MDA'
);
foreach($agents as $i){
if(strstr($_SERVER['HTTP_USER_AGENT'],$i)){
header("Location: ".$redirect);
exit;
}
}
Leave a Reply
You must be logged in to post a comment.