nakome
2/19/2014 - 7:49 PM

Redirect Mobile or Web

Redirect Mobile or Web

<?php
	$is_mobile = FALSE;
	$user = $_SERVER['HTTP_USER_AGENT'];
	$user_mobile = "Android, AvantGo, Blackberry, Blazer, Cellphone, Danger, DoCoMo, EPOC, EudoraWeb, Handspring, HTC, Kyocera, LG, MMEF20, MMP, MOT-V, Mot, Motorola, NetFront, Newt, Nokia, Opera Mini, Palm, Palm, PalmOS, PlayStation Portable, ProxiNet, Proxinet, SHARP-TQ-GX10, Samsung, Small, Smartphone, SonyEricsson, SonyEricsson, Symbian, SymbianOS, TS21i-10, UP.Browser, UP.Link, WAP, webOS, Windows CE, hiptop, iPhone, iPod, portalmmm, Elaine/3.0, OPWV";
	$navigator_user = explode(',',$user_mobile);
	foreach($navigator_user AS $navigator){
		if(eregi(trim($navigator),$user)){
			$is_mobile = TRUE;
		}
	}

	if($is_mobile ==TRUE){
		header('Location:http://mobile.com/web');   // Mobile url
	}
	else{
		header('Location:http://web.com');  //  Web url
	}
?>