[英]Codeigniter language segments in routing
I have this: 我有这个:
$route['(:any)'] = "front/$1"; // front
$route['admin/(:any)'] = "admin/$1"; // admin
i want to make url like this: 我想像这样制作网址:
mysite.com/en/somecontroller/somemethod
mysite.com/ru/somecontroller/somemethod
etc...
i guess something like this: 我猜是这样的:
$route['(:any)'] = "front/$1"; // front
$route['(:any)/(:any)'] = "front/$2";
$route['admin/(:any)'] = "admin/$1"; // admin
$route['(:any)/admin/(:any)'] = "admin/$2";
but I get errors when the first segment is language, CI thinks that is a controller 但是当第一段是语言时我得到错误,CI认为这是一个控制器
If you are using CodeIgniter's language class , then this URI Language Identifier class extension should do exactly what you want. 如果您正在使用CodeIgniter的语言类 ,那么此URI语言标识符类扩展应该完全按照您的意愿执行。
This language class extension allows you to automatically prefix all site urls with a language abbreviation that is pre-defined in your config file or from a link and automatically load the corresponding language translation file, the route will then be corrected by the route regex for everything to work as normal.
此语言类扩展允许您使用在配置文件中预定义的语言缩写或从链接自动为所有站点URL添加前缀并自动加载相应的语言翻译文件,然后路由将由路由正则表达式更正所有内容像往常一样工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.