2014-01-18 56 views
1

我現在面臨一個小問題,現在用笨...笨404錯誤在控制器/法路線

我有以下文件:

applications/controllers/home/entretiens.php 

,看起來像這樣:

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 

class Entretiens extends CI_Controller 
{ 
    public function index() 
    { 
     if($this->session->userdata('logged_in')) 
     { 
      $data['page'] = "entretiens"; 
      $session_data = $this->session->userdata('logged_in'); 
      $data['prenom'] = $session_data['prenom']; 
      $this->load->model("Entretiens_model"); 
      $data['entretiens'] = $this->Entretiens_model->getAllEntretiens($session_data['id']); 
      $data['main_content'] = 'home/entretiens_view.php'; 
      $this->load->template('entretiens_view', $data); 
     } 
     else 
     { 
      //If no session, redirect to login page 
      redirect('home/login', 'refresh'); 
     } 
    } 

    public function ajouter() 
    { 
     echo 'Test'; 
    } 
} 

?> 

如果我使用我的瀏覽器:myurl/entretiens我得到正確的頁面(控制器「entretiens」的索引方法),但是如果我轉到myurl/entretiens/ajouter,我所得到的只是CodeIgniter中的404。

這裏是我的路線文件:

$route['default_controller'] = "home/index_controller"; 
$route['login'] = "home/login_controller"; 
$route['user'] = "home/user_controller"; 
$route['entretiens'] = "home/entretiens"; 
$route['404_override'] = ''; 

而且config.php(當然,有趣的部分):

$config['base_url'] = 'http://dev.hinsolite.com/'; 
$config['index_page'] = ''; 
$config['uri_protocol'] = 'AUTO'; 

而且我.htaccess

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

(此問題是所有的控制者,而不僅僅是entretiens ...

回答

1

改變你routes.php相關線路如下:

$route["entretiens(.*)"] = "home/entretiens$1"; 

此將其視爲通配符,entretiens後一切都將被傳遞給home/entretiens

+0

工作很好! 感謝您的幫助! –

+0

@YanisBoucherit不客氣。 –