I'm using Unity mobile to create a mobile site. This tool was an option in the web presence builder. I've tried to implement the PHP code that is generated through them to redirect mobile users to the mobile site but it is not working. When I put it in I just get a blank page, and not the mobile site. Can anyone help? Do I put the code site-wide or just in the home page?
Here is the code I'm using.
I've tried also adding <?php to the beginning of the code in the script. Any ideas on what I'm missing?
Here is the code I'm using.
Code:
$nmpar = 'nomobile';
$nmpart = 'true';
$res = isset($_GET[$nmpar]) ? trim($_GET[$nmpar]) : '';
if (!empty($res) && strcasecmp($res, $nmpart) == 0) { setcookie($nmpar, $nmpart); }
else if (!isset($_COOKIE[$nmpar]) || strcasecmp($_COOKIE[$nmpar], $nmpart) != 0) {
$mobile_site_url = 'http://mobi.inlandnwpc.com/';
$is_mobile = false;
$browser = $_SERVER['HTTP_USER_AGENT'];
$accept = $_SERVER['HTTP_ACCEPT'];
if (isset($_SERVER['HTTP_X_WAP_PROFILE'])||isset($_SERVER['HTTP_PROFILE'])) {
$is_mobile = true;
} else if(preg_match('/(Alcatel|Asus|Android|BlackBerry|Ericsson|Fly|Huawei|i-mate|iPAQ|iPhone|iPod|LG-|LGE-|MDS_|MOT-|Nokia|Opera Mini|Opera Mobi|Palm|Panasonic|Pantech|Philips|Sagem|Samsung|Sharp|SIE-|Symbian|Vodafone|Voxtel|webOS|Windows CE|Windows Phone|ZTE-)/i',$browser)) {
$is_mobile = true;
} else if ((strpos($accept,'text/vnd.wap.wml')>0) || (strpos($accept,'application/vnd.wap.xhtml+xml')>0)) {
$is_mobile = true;
};
if ($is_mobile)
header('Location: ' . $mobile_site_url);
}
I've tried also adding <?php to the beginning of the code in the script. Any ideas on what I'm missing?