Hi, I designed a web site for a client, and I got thisredirect script to work on IPHONE, but it doesnt work on blackberry at all, even if I replace the 'iphone' with 'blackberry'. Any help GREATLY appreciated! Cant get this thing to work! <?php if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== FALSE) { header('Location: http://www.israla.com/mobile/index.php'); } ?>
run a test and log the useragent blackberry sends.. <?php echo $_SERVER['HTTP_USER_AGENT'].'<br />'; $x = file_put_contents("blackberry_user_agent.txt",$_SERVER['HTTP_USER_AGENT']); if($x > 0) { echo 'user_agent written to file'; } else { echo 'Could not write user_agent to file'; } ?> PHP: save that and browse it with a blackberry..
<?php //array of cellphone names $cellphone_names = array('iphone', 'blackberry', 'nokia'); $escaped = array_map('preg_quote', $cellphone_names); if (preg_match('~\b('.implode("|", $escaped).')\b~i', $_SERVER['HTTP_USER_AGENT'])) { //redirect to mobile version... header("location: http://{$_SERVER['HTTP_HOST']}/mobile"); } ?> PHP:
hello all; once class... browse.php http://www.mavrick.id.au/browser-v1-6.zip PHP: <?php include 'browser.php'; // browser class $browser = new Browser(); if( $browser->getBrowser() == Browser::PLATFORM_BLACKBERRY && $browser->getVersion() >= 2 ) { header ("Location: http://www.israla.com/mobile/index.php"); die; exit(); } ?> PHP: good bye...