我正在使用CodeIgniter与多种语言和城市网站。对于以下多种语言,路由工作正常(URL = www.mywebsite.com/en/
)
/*
| -------------------------------------------------------------------------
| Multilingual routing (use 2 characters (e.g. en, zh, cn, es) for switching languages)
| -------------------------------------------------------------------------
*/
$route['^(\w{2})/(.*)$'] = '$2';
$route['^(\w{2})$'] = $route['default_controller'];
但是当像www.mywebsite.com/en/del/
这样的URL然后路由不起作用时,代码如下
$route['^(\w{2})/^(\w{3})$'] = $route['default_controller'];
在哪里我错了,有什么想法吗?
这是因为你的正则表达式是不正确的,^
标志着字符串的开头,你不能像这样在中间使用它。请尝试使用以下代码(DEMO):
$route['^(\w{2})/(\w{3})$'] = $route['default_controller'];