携帯電話のアクセスのみ許可(ユーザーエイジョント)

携帯電話からのアクセスのみ画面に表示したい時がある

そんなときはユーザーエイジェントを取り出してパソコン以外を表示できるようにすればよい。
というお話は、よく聞くお話です。

なので、今回QRコードを読み出して、それから携帯だけアクセスできるページを作成することにする。

PHPのスクリプトは以下のようになる

$agent = $_SERVER[’HTTP_USER_AGENT’];

if(ereg(”DoCoMo”,$agent)){
header(”Location: http://www.7starweb.com/docomo/”);
exit;
}
elseif(ereg(”UP.Browser”,$agent)){
header(”Location: http://www.7starweb.com/au/”);
exit;
}
elseif(ereg(”SoftBank”,$agent)){
header(”Location: http://www.7starweb.com/softbank/”);
exit;
}
elseif(ereg(”Vodafone”,$agent)){
header(”Location: http://www.7starweb.com/softbank/”);
exit;
}
elseif(ereg(”J-PHONE”,$agent)){
header(”Location: http://www.7starweb.com/softbank/”);
exit;
}
else{
header(”Location: http://www.7starweb.com/pc/”);
exit;
}




You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply