PHPでキャリアごとにリダイレクト | φ(..)メモとして残しておこう…

PHPでキャリアごとにリダイレクト

タイトルどおりのリダイレクトプログラムのメモ。


<?php
/*
$agent = $_SERVER['HTTP_USER_AGENT'];
if (
(strpos($agent, 'iPhone') !== false && strpos($agent, 'iPad') === false) || strpos($agent, 'iPod') !== false || strpos($agent, 'Android') !== false)
{header("Location: ./smart.html");}
else {

if(ereg("^DoCoMo", $agent)){header("Location: ./docomo.php");}
else if(ereg("^J-PHONE|^Vodafone|^SoftBank", $agent)){header("Location: ./sb.php");}
else if(ereg("^UP.Browser|^KDDI", $agent)){header("Location: ./au.php");}

else {"Location: ./pc.html");}
}
*/
?>


ということで。
JavaScriptだと、JavaScriptに対応していない機種の場合に動作しないのでPHPでやったほうがいい。