所以我正在使用Codeigniter 2.1 Internationalization i18n 库,我需要调整我的路由以在我删除控制器名称的短 url 中使用语言参数:
$route['default_controller'] = "home";
#$route['^(en|es|ro)/(.+)$'] = "$2";
#$route['^(en|es|ro)$'] = $route['default_controller'];
$route['results$'] = "fetch/results";
$route['video/(:any)'] = "fetch/video/$1";
$route['tag/(:any)'] = "fetch/tag/$1";
$route['404_override'] = '';
所以我需要做这个工作http://localhost/app/en/results?query=t-shirts
而不是http://localhost/app/en/fetch/results?query=t-shirts
我怎样才能做到这一点?
编辑:
$route['^(en|es|ro)/results$'] = "fetch/results";
$route['^(en|es|ro)/video/(:any)'] = "fetch/video/$1";
$route['^(en|es|ro)/video/(.+)$'] = $route['^(en|es|ro)/(.+)$'] = "$2";"fetch/video/$2";
以上都不起作用。
如果我能http://localhost/app/en/fetch/video/asfasf
完美地工作
这不http://localhost/app/en/video/asfasf
我得到的错误是 404:
404 Page Not Found
The page you requested was not found.
发现问题
所以,出于某种原因,有这个设置:$route['^(en|es|ro)/(.+)$'] = "$2";
在我试图做的是导致问题之前。