我試圖使用另一個控制器打電話給我一個控制器重定向,像這樣..控制器404問題笨
歡迎控制器
public function login(){
$rules=array(
array(
'field'=>'username',
'label'=>'Username',
'rules'=>'required|trim'
),
array(
'field'=>'password',
'label'=>'Password',
'rules'=>'trim|required'
),
);
$this->form_validation->set_rules($rules);
if($this->form_validation->run()==TRUE){
$data=array(
'username'=>$this->security->xss_clean($this->input->post('username')),
'password'=>$this->security->xss_clean($this->input->post('password'))
);
$account_details=$this->users_model->getCredentials($data);
if($account_details->num_rows()==1){
$account_details=$account_details->result();
$this->session->set_userdata(array('username'=>$account_details[0]->username));
redirect(site_url('navigation'),'refresh');
}else{
$this->session->set_flashdata('message','Wrong username or password.');
$this->show_login();
}
}else{
$this->session->set_flashdata('error',validation_errors());
$this->show_login();
}
}
導航控制器
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
Class Navigation extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->model('Users_access_model');
}
public function index(){
$data['links']=$this->Users_access_model->get_links($this->session->userdata['username']);
$this->load->view('common/header');
$this->load->view('common/view_navigation');
$this->load->view('common/scripts');
}
}
?>
這個出來在我的地址欄中
http://localhost/piercapitan/index.php/navigation
的我得到這個
404 Page Not Found
The page you requested was not found.
這是我的配置
$config['base_url'] = 'http://localhost/piercapitan/';
這是我的.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
我以前使用的重定向,但我是用它從我的Windows機器,但當我轉移到Ubuntu,那是我得到這個問題的時間。謝謝。
嘗試使用http://localhost/piercapitan/index.php/Navigation。資本「N」然後告訴我它是否工作?並嘗試與此http://localhost/piercapitan/index.php/navigation/index。和http://localhost/piercapitan/index.php/Navigation/index並嘗試以上三次發生,並告訴我它仍然顯示404? – Bhavin
localhost/piercapitan/index.php /導航 - >這工作對我來說..我如何更改我的代碼來反映這一點? – Ibanez1408