繁体   English   中英

页面重定向问题codeigniter:404错误

[英]page redirect issue codeigniter : 404 error

我正在使用CodeIgniter创建一个应用程序。

输入正确的电子邮件和密码后,应将我重定向到仪表板,但得到以下重定向:/ auth / login,它显示 在此处输入图片说明

我可以澄清一下,我允许mod_rewrite,添加了写base_url并允许在apache上进行连接

我的Config.php

   $config['base_url'] = 'http://127.0.0.1:8000/stock-v2/'; 

我的控制器:

 public function login()
{

    $this->logged_in();

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

    if ($this->form_validation->run() == TRUE) {
        // true case
        $email_exists = $this->model_auth->check_email($this->input->post('email'));

        if($email_exists == TRUE) {
            $login = $this->model_auth->login($this->input->post('email'), $this->input->post('password'));

            if($login) {

                $logged_in_sess = array(
                    'id' => $login['id'],
                    'username'  => $login['username'],
                    'email'     => $login['email'],
                    'logged_in' => TRUE
                );

                $this->session->set_userdata($logged_in_sess);
                redirect('dashboard', 'refresh');
            }
            else {
                $this->data['errors'] = 'Incorrect username/password combination';
                $this->load->view('login', $this->data);
            }
        }
        else {
            $this->data['errors'] = 'Email does not exists';

            $this->load->view('login', $this->data);
        }   
    }
    else {
        // false case
        $this->load->view('login');
    }   
}

    */
public function logout()
{
    $this->session->sess_destroy();
    redirect('auth/login', 'refresh');
}

有人可以帮忙吗?

更改您的.htaccess文件。 将其粘贴到应用目录中的.htaccess中(与应用程序处于同一级别),将可以正常运行:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

并在conf.php中:

$config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].'/stock-v2/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

然后像这样使用regirect而不刷新:

redirect(base_url('dashboard'));

签入http.conf,是否允许您的域覆盖?

<Directory "/var/www">
    AllowOverride All
    # Allow open access:
    Require all granted
</Directory>

您必须配置您的基本URL。

如果您在本地服务器上工作,请尝试以下操作:

$config['base_url'] = 'http://localhost/stock-v2/';

否则(直播)

$config['base_url'] = 'http://<put your domain here>';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM