douwei1921 2014-12-01 15:48
浏览 380
已采纳

在PHP中重定向抛出520错误CloudFlare

I am using cloudflare with codeigniter framework and I am facing strange problem while trying to redirect the script to another page when the action is completed, server use to throw error 520(cloudflare server)

$input = $this->input->post();

if(!empty($input)){

        $this->load->library('form_validation');

        $this->form_validation->set_rules('email', 'Email', 'required|email');
        $this->form_validation->set_rules('password', 'Password', 'required');

        if ($this->form_validation->run() == TRUE)
        {
            $r = $this->userModel->login($input["email"], $input["password"]);
            if($r["success"] == "t"){

                $this->userModel->setSession($r["_user_id"], $r["token"]);

                //Both redirect methods does not works
                //echo '<html><head><META http-equiv="refresh" content="0;URL='.$this->glob->exec_redirect().'"></head><body></body></html>';
                redirect($this->glob->exec_redirect());
                die();
            }else{
                $data["errors"] = $r["message"];
            }
        }else
            $data["errors"] = validation_errors();
    }
    $this->load->view("user/login", $data);

This script work fine without cloudflare, also the script work fine with cloudflare without redirect functions. Demos:

Sample which throws error

user: test

pass: test12

Sometimes you should try more then once to crash

Sample without redirect

Works fine, user is logged in just have to redirect Manuel.

Regards.

  • 写回答

2条回答 默认 最新

  • douquan3294 2014-12-01 16:39
    关注

    I logged in, and it worked. Then, I logged out and tried to login again and I saw the 520 error you're talking about.

    I think it has something to do with your redirect URL.

    https://www.plac24.com/user/login?rdr=http%3A%2F%2Fwww.plac24.com%2F
    

    As you're redirecting them to your website, do you need the http://?

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

报告相同问题?

悬赏问题

  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目