nee*_*eko 0 php internet-explorer redirect user-agent
我试图将用户重定向到另一个页面,如果他们使用Internet Explorer但这个代码不重定向它,它正常加载页面即ie
我尝试了不同的MSIE变体,但似乎没有任何效果
session_start();
if (strpos($_SERVER['HTTP_USER_AGENT'], '/MSIE/i') !== false){
header('Location: /ie.php');
die();
}else{
echo "User Agent not recognised.";
}
Run Code Online (Sandbox Code Playgroud)
有人有主意吗?
试试这个:
session_start();
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false){
header('Location: /ie.php');
die();
}else{
echo "User Agent not recognised.";
}
Run Code Online (Sandbox Code Playgroud)
原因是strpos
第二个参数,即针,不应该是正则表达式.