zoukankan      html  css  js  c++  java
  • Apache本地环境下出现循环重定向

    最近发现一个很奇怪的问题,用了很久的apache+php访问项目,昨天突然不行了,出现了这个

    然后我一点点测试,我用的是TP框架,Indexaciton的index中调用框架里的一个redirect函数

    public function index() {
            /*if(empty($_SESSION['admin']['admin_id'])) {
               $this->redirect('Public/login','' , 0,'页面跳转中~');
            }*/
    
            if(empty($_SESSION['admin']['admin_id'])) {
                if(!checkCookieAdmin()){
                    $this->redirect('Public/login','' , 0,'页面跳转中~');
                }
            }     
            $this->display('Public:index');
        }

    在tp action.class.php redirect函数中调用redirect

    protected function redirect($url,$params=array(),$delay=0,$msg='') {
            if(C('LOG_RECORD')) Log::save();
            $url    =   U($url,$params);
            redirect($url,$delay,$msg);
        }

    functions.php 里面的redirect函数

    // URL重定向
    function redirect($url,$time=0,$msg='')
    {
        //多行URL地址支持
        $url = str_replace(array("
    ", "
    "), '', $url);
        if(empty($msg))
            $msg    =   "系统将在{$time}秒之后自动跳转到{$url}!";
        if (!headers_sent()) {
            // redirect
            if(0===$time) {
                header("Location: ".$url);
            }else {
                header("refresh:{$time};url={$url}");
                echo($msg);
            }
            exit();
        }else {
            $str    = "<meta http-equiv='Refresh' content='{$time};URL={$url}'>";
            if($time!=0)
                $str   .=   $msg;
            exit($str);
        }
    }

    这样分析下来,定向都是指向Public中的login的,但是不知道为什么就是不渲染html页面,始终出现循环重定向。

    解决的办法:换成了Ngnix服务器,竟然好了!好了!!!!很是神奇啊。。。。

    希望各位大神们道出其中的奥秘!

  • 相关阅读:
    TCP源码—连接建立
    TCP系列02—连接管理—1、三次握手与四次挥手
    TCP系列01—概述及协议头格式
    ubuntu软件管理apt与dpkg
    318. Maximum Product of Word Lengths
    317. Shortest Distance from All Buildings
    316. Remove Duplicate Letters
    315. Count of Smaller Numbers After Self
    314. Binary Tree Vertical Order Traversal
    313. Super Ugly Number
  • 原文地址:https://www.cnblogs.com/angellating/p/5853903.html
Copyright © 2011-2022 走看看