[英]Redirect all 404 error pages to custom 404 page Codeigniter HMVC
[英]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.