繁体   English   中英

移动检测错误重定向过多

[英]Mobile Detect error too many redirects

我正在使用一个插件来检测设备是移动设备还是任何PC
所以这是代码

require_once ('Mobile-Detect-2.8.27/Mobile_Detect.php');

$detect = new Mobile_Detect;
// Any mobile device (phones or tablets).


if ( $detect->isMobile() ) {
}else{
header("Location:../login");
}
// Any tablet device.
if( $detect->isTablet() ){
}
else{
header("Location:../login");
}

// Exclude tablets.
if( $detect->isMobile() && !$detect->isTablet() ){
}else{  
header("Location:../login");
}

// Check for a specific platform with the help of the magic methods:
if( $detect->isiOS() ){
}else{
header("Location:../login");
}

if( $detect->isAndroidOS() ){
}else{
header("Location:../login");
}

如您所见,这将重定向到另一个页面。
但是当我用这个手机时,Chrome显示错误

此页面不起作用
重定向太多次了有什么问题?

确保没有任何标题之前没有输出,并使用exit; 每个标题之后

  header("Location:../login");
  exit;

谢谢大家,但我得到了答案,我是我的错误和愚蠢。 实际上,当插件将设备检测为移动设备时,它会重定向到该应用程序的移动版本,然后该应用程序的移动版本具有另一个可以检测到任何计算机的插件,因此当涉及到移动版本时,它已更改为现在可以检测电话转到计算机版本,然后转到移动设备,依此类推。 因此,我为自己的错误感到抱歉,并感谢大家的帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM