使用routes.php的多种语言

时间:2012-04-25 03:38:00

标签: codeigniter url-rewriting

因为我正在为我的应用程序添加多语言支持,而且我的routes.php出现了问题,其中某些路由已停止工作。

似乎任何一个细分都有效,任何两个或两个以上都没有。

如何解决这个问题的任何帮助将非常感激。

Routes.php摘录:

// URI like '/en/about' -> use controller 'about'
$route['^(en|br)/(.+)$'] = "$2";
$route['dashboard'] = 'dashboard';    //THIS WORKS
$route['profile'] = 'profile/profile_list';
$route['profile_list/page'] = 'profile/profile_list';    //THIS DOESN'T
$route['profile_list/page/(:any)'] = 'profile/profile_list/$1';
$route['profile/update'] = 'profile/update';
$route['profile/(:any)'] = 'profile/$1';
$route['default_controller'] = 'landing';
// '/en', '/de', '/fr' and '/nl' URIs -> use default controller
$route['^(en|br)$'] = $route['default_controller']; 

1 个答案:

答案 0 :(得分:1)

使用以下信息找出答案:Codeigniter forum

只需添加此变量,其中包含我使用的任何双字母语言代码的网址段:

$prepended_lang = "(?:[a-zA-Z]{2}/)?"; 

然后相应地修改路线:

$route[$prepended_lang.'logout'] = 'login/logout';
相关问题