duanfeng3879 2012-10-12 13:50
浏览 24
已采纳

php internet explorer redirect header无法正常工作

im trying to redirect users to another page if they are using internet explorer but this code doen't redirect them it loads the page up as normal on i.e.

I have tried different variations of MSIE but nothing seems to work

session_start();

  if (strpos($_SERVER['HTTP_USER_AGENT'], '/MSIE/i') !== false){
header('Location: /ie.php');
die();
}else{
echo "User Agent not recognised.";
}

any one have any ideas?

  • 写回答

4条回答 默认 最新

  • doupeizheng3918 2012-10-12 13:53
    关注

    try this:

    session_start();
    
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false){
        header('Location: /ie.php');
        die();
    }else{
        echo "User Agent not recognised.";
    }
    

    The reason is that strpos's second parameter, the needle, is not supposed to be a regular expression.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计