Codeigniter (:任意)路由块404_覆盖路由

Codeigniter (:任意)路由块404_覆盖路由,codeigniter,routing,Codeigniter,Routing,我有以下路线: $route['default_controller'] = 'Pages/view/$1'; $route['product/(:any)'] = 'pages/product/$1'; $route['category/(:any)'] = 'pages/category/$1'; $route['(:any)'] = 'pages/view/$1'; 但是当我想添加$route['404_override']='My404'my任何路由都停止工作,我无法访问我的主页,比如

我有以下路线:

$route['default_controller'] = 'Pages/view/$1';
$route['product/(:any)'] = 'pages/product/$1';
$route['category/(:any)'] = 'pages/category/$1';
$route['(:any)'] = 'pages/view/$1';

但是当我想添加
$route['404_override']='My404'
my
任何
路由都停止工作,我无法访问我的主页,比如
base\u url('home')…

你需要为home controller定义路由。问题是您已经定义了
$route['(:any)]='pages/view/$1'将覆盖所有未定义的路由。因此,您需要更改
$route['(:any)]='pages/view/$1'指向其他内容,或者需要定义home的路由,例如:
$route['home']='home\u controller'

当然,它将阻止它,因为(:any)将匹配任何内容,因此没有页面将返回404…@Pieter Cheers!