我必須製作2個我的網站,即1個移動電話版本和1個PC版本。所以我有一個腳本如下: -檢測移動設備的腳本是什麼
<?php
if (stristr($ua, "Windows CE") or stristr($ua, "AvantGo") or
stristr($ua,"Mazingo") or stristr($ua, "Mobile") or stristr($ua, "T68") or
stristr($ua,"Syncalot") or stristr($ua, "Blazer") or
stristr($ua,"Mozilla") or stristr($ua,"Firefox"))
{
$DEVICE_TYPE="MOBILE";
}
if (isset($DEVICE_TYPE) and $DEVICE_TYPE=="MOBILE")
{
$location='mobile/entry.html';
header ('Location: '.$location);
exit;
}
else
{
$location='entry.html';
header ('Location: '.$location);
exit;
}
?>
該腳本可以與電腦效果很好,但如果我試圖從手機訪問我的網站,我想我不能重定向到同一頁面。
任何人都可以幫我解決這個問題嗎?
在此先感謝。
可能重複【如何檢測手機瀏覽器功能(http://stackoverflow.com/questions/3428234/how-to-detect-mobile-browser -capability) – 2010-08-12 10:40:07
@Pekka大多數鏈接在Sarfraz發佈不幸工作 – Sotiris 2010-08-12 10:55:09