Codeigniter路由子文件夹无法正常工作

时间:2014-05-13 11:14:59

标签: codeigniter routes

$route['default_controller'] = "index";

$route['404_override'] = '';

$route['(:any)'] = 'index/$1';

$route['admin'] = "admin/index"; 

$route['admin/add_category'] = "admin/index/add_category";

作品:

$route['admin/edit_category/2']  = "admin/index/edit_category/2";

无效:

$route['admin/edit_category/(:any)']  = "admin/index/edit_category/$1";

1 个答案:

答案 0 :(得分:0)

尝试将您的规则放在捕获所有内容的路线之前

$route['admin'] = "admin/index"; // no params at first

$route['admin/add_category'] = "admin/index/add_category"; // extend first rule

$route['admin/edit_category/(:any)']  = "admin/index/edit_category/$1"; // and one more

$route['default_controller'] = "index"; // default settings

$route['404_override'] = '';

$route['(:any)'] = 'index/$1'; // ok, now we can brake MVC pattern, but should we?

例如我的一个路由文件(确实有效):

$route['project-admin/login'] = "project-cms/user/index";
$route['project-admin/recovery'] = "project-cms/user/recovery";
$route['project-admin'] = "project-cms/admin/index";
$route['project-admin/(:any)'] = "project-cms/admin/$1";
$route['project-admin/(:any)/(:any)'] = "project-cms/admin/$1/$2";