dongqiu8375 2019-04-05 02:00
浏览 54

POST提交后CodeIgniter 302

I recently move my codeigniter project to Nginx. It uses SSL and I can access the landing page of the site.

However, it's just the login page. I can't get through it. Whenever I submit the POST data, it just redirects to itself.

I tried to print_r() the POST data if there is and I am able to see it but nothing more (I use ion auth).

Here's my login controller:

public function login()
{
    if($this->input->post()){
        echo "Yow"; //this works if you put die() nex to it.
    }
    if($this->ion_auth->logged_in() && !$this->ion_auth->is_admin())
    {
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
        die();
        //echo "here"; die();
        //redirect('dashboard'); //disabled upon further notice
        redirect('directory');
    } else if($this->ion_auth->logged_in() && $this->ion_auth->is_admin()){
        redirect('admin');
    }else {
        $this->data['pagetitle'] = 'brunchwork | Login';
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', 'Username', 'trim|required');
        $this->form_validation->set_rules('password', 'Password', 'trim|required');
        $msg = $this->session->flashdata('message');
        $this->data['message'] = $msg['message'];
        $this->data['alert_type'] = $msg['alert_type'];
        if ($this->form_validation->run() === FALSE)
        {
            $this->render('member/login');
        } else {
            if($this->input->post('remember_me')){
                $remember = 1;
            } else {
                $remember = 0;
            }
            //$remember = (bool) $this->input->post('remember_me');
            $username = $this->input->post('username');
            $password = $this->input->post('password');
            if ($this->ion_auth->login($username, $password, $remember))
            {
                $sid = session_id();
                if($sid) {
                    //session_start();
                } else {
                    session_start();
                }
                //session_start();
                //redirect('dashboard'); //disabled upon further notice
                if($this->ion_auth->logged_in() && $this->ion_auth->is_admin())
    {
        //redirect('dashboard'); //disabled upon further notice
        redirect('admin');
    } else {
        redirect('directory');
    }
            }
            else
            {
                $_SESSION['message'] = $this->ion_auth->errors();
                $this->session->mark_as_flash(array('message' => $_SESSION['message'], 'alert_type' => 'error'));
                redirect('login');
            }
        }
    }
}

And my nginx conf:

server {
listen 80;
listen [::]:80;
server_name members.brunchwork.com www.members.brunchwork.com; 
return 307 https://members.brunchwork.com$request_uri;
# return 301 https://$server_name$request_uri;
# root   /home/dev/members.brunchwork.com/public_html;
# index index.html index.php;

}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name members.brunchwork.com www.members.brunchwork.com; 
root   /home/dev/members.brunchwork.com/public_html;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /home/dev/members.brunchwork.com/godaddy-certs/bundle.crt;  
ssl_certificate_key /home/dev/members.brunchwork.com/godaddy-certs/members.brunchwork.com.key;


# Logging
error_log /home/dev/members.brunchwork.com/public_html/log/access_log;
access_log /home/dev/members.brunchwork.com/public_html/log/error_log;

location / {
#       Check if a file or directory index file exists, else route it to index.php.
#       try_files $uri $uri/ =404;
#       try_files $uri $uri/ /index.php?/$request_uri;
#       try_files $uri $uri/ /index.php;
    rewrite ^(.*)$ /index.php;
#       file doesn't exist, let CI handle it
    if (!-f $request_filename) {
            #rewrite ^(.*) /index.php?$1 last;
    rewrite ^(.*)$ /$1.php;
        }
  }

location ~ \.php {
#       try_files $uri $uri/ =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param SCRIPT_FILENAME /home/dev/members.brunchwork.com/public_html$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
#       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors on;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
     expires max;
     log_not_found off;
}

location ~ /\.ht {
    deny all;
}
}

What could be causing this? I was able to fix this yesterday when there's no SSL setup yet but I can't find where I got the solution so I'm here.

Any help is highly appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探