ユーザーエージェントを取得してリンク先を分ける
EC-CUBEのSmarty機能を無視してページを作成していると、自動で生成されるスマホ・ガラケー用のページにリダイレクトしなきゃならないので、PHPでユーザーエージェントを取得してリダイレクト。
//▽ユーザーエージェント判別▽
$agent = $_SERVER['HTTP_USER_AGENT'];
$mobile = "モバイル用ページURL";
$pc = "PC用ページURL";
if (
( strpos($agent, 'iPhone') !== false && strpos($agent, 'iPad') === false ) ||
strpos($agent, 'iPod') !== false ||
strpos($agent, 'Android') !== false
)
{ $link = $mobile; }
elseif( eregi("DoCoMo",$agent) ){ $link = $mobile; }
elseif( eregi("UP\.Browser",$agent) ){ $link = $mobile; }
elseif( eregi("J-PHONE",$agent) ){ $link = $mobile; }
elseif( eregi("Vodafone",$agent) ){ $link = $mobile; }
elseif( eregi("SoftBank",$agent) ){ $link = $mobile; }
elseif( eregi("J-EMULATOR",$agent) ){ $link = $mobile; }
else{ $link = $pc; }
//△ユーザーエージェント判別△
print <<< EOF
<script>
parent.location.href='{$link}';
</script>
こんな感じかな…
//▽ユーザーエージェント判別▽
$agent = $_SERVER['HTTP_USER_AGENT'];
$mobile = "モバイル用ページURL";
$pc = "PC用ページURL";
if (
( strpos($agent, 'iPhone') !== false && strpos($agent, 'iPad') === false ) ||
strpos($agent, 'iPod') !== false ||
strpos($agent, 'Android') !== false
)
{ $link = $mobile; }
elseif( eregi("DoCoMo",$agent) ){ $link = $mobile; }
elseif( eregi("UP\.Browser",$agent) ){ $link = $mobile; }
elseif( eregi("J-PHONE",$agent) ){ $link = $mobile; }
elseif( eregi("Vodafone",$agent) ){ $link = $mobile; }
elseif( eregi("SoftBank",$agent) ){ $link = $mobile; }
elseif( eregi("J-EMULATOR",$agent) ){ $link = $mobile; }
else{ $link = $pc; }
//△ユーザーエージェント判別△
print <<< EOF
<script>
parent.location.href='{$link}';
</script>
こんな感じかな…