Sabri Aziri
Sabri Aziri

Reputation: 4174

Redirect in php throws 520 error 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.

Upvotes: 0

Views: 2348

Answers (2)

damoncloudflare
damoncloudflare

Reputation: 2087

Are you doing anything that sends large cookies or headers? That's a possible cause & support can help troubleshoot.

Upvotes: 0

Craig
Craig

Reputation: 1823

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://?

Upvotes: 1

Related Questions