携帯電話のユーザーエージェントを取得して振り分ける
// UA 取得 $agent = $_SERVER['HTTP_USER_AGENT']; if(ereg("^DoCoMo", $agent)){ $env = "docomo"; }elseif(ereg("^UP.Browser|^KDDI", $agent)){ $env = "au"; }elseif(ereg("^J-PHONE|^Vodafone|^SoftBank", $agent)){ $env = "softbank"; }elseif(ereg("^MOT-|^WILLCOM", $agent)){ $env = "willcom"; }else{ $env = "pc"; }
$agent = $_SERVER['HTTP_USER_AGENT']; $hoge = array('DoCoMo', 'UP.Browser', 'KDDI', 'J-PHONE', 'Vodafone', 'SoftBank', 'MOT-', 'WILLCOM' ); $env = 'pc'; $i = 0; while($hoge[$i] != ''){ if(preg_match("/$hoge[$i]/", $agent)){ $env = 'mobile'; } $i ++; } if($env != 'pc') header("Location: /m/index.php");