我在從移動站點重定向後保持主站點顯示時出現問題。移動站點只重定向到主站點主頁
如果檢測到移動設備,它將重定向到移動網站。移動網站上有一個「主站點」鏈接,點擊後可將您帶到主站點。由於某種原因,當您點擊主站點主頁上的鏈接時,它不會停留在主站點上,它會重定向回移動站點。
我假設cookie沒有正確存儲。
<?php
@include("Mobile_Detect.php");
$detect = new Mobile_Detect();
$allow_mobile = isset($_COOKIE['mobile'])? true:false;
if (isset($_GET['mobile'])) {
if ($_GET['mobile']=='false'){
setcookie("mobile", "");
$allow_mobile = false;
} else {
setcookie("mobile", true, time() + 31536000, "/");
$allow_mobile = true;
}
}
if ($allow_mobile && $detect->isMobile()){
if (!$detect->isTablet()) {
header("Location:http://mobilesite.mobi");
}
}
$not_mobile_cookie = isset($_COOKIE['notmobile'])? true:false;
if (isset($_GET['mobile'])) $not_mobile_cookie = $_GET['mobile'];
if ($not_mobile_cookie==false && $detect->isMobile()){
if (!$detect->isTablet()) {
header("Location:http://mobile.mobi");
}
}
?>
這可能是簡單的東西,但我看不出來弄明白。
謝謝!
你追加到主站點鏈接的變量是什麼? – MrCode
變量是/?mobile = false – Craig