2013-02-08 59 views
0

我有這條路線定義在routes.php $route['user'] = "user_controller";。用戶控制器有一個方法logout()但是當我嘗試這個URI user/logout我得到一個404以同樣的方式,當我使用這個URI user/index我得到一個404CodeIgniter:瞭解路線

routes.php文件

// custom routes 
$route['start'] = "start_controller"; 
$route['register'] = "register_controller"; 
$route['user'] = "user_controller"; 

// other routes 
$route['default_controller'] = "start_controller"; 
$route['404_override'] = ''; 

回答

1

根據CI

注:路由將按照它們定義的順序運行。較高的路線 將始終優先於較低的路線。

$route['default_controller']$route['404_override']必須始終在最前面上述別人

$route['user/logout'] = "user_controller/logout"; 
$route['user/index'] = "user_controller"; 

例子,我將鍵入一個user/logout那麼它將繼續user_controller/logout你必須定義URL你想重定向

0

是的,你必須爲每個特定的方法指定一個路由。

下面是從我routes.php文件的例子:

/* User Authentication Controller */ 
$route['login']  = "auth/login"; 
$route['logout'] = "auth/logout"; 
$route['register'] = "auth/register"; 
$route['forgot'] = "auth/forgot";