多语言 URL
在 codeigniter 中,控制器的名称反映了 URL。 但我的问题是,如何在不复制/粘贴所有控制器的情况下创建多语言 URL。
示例:
- 在英语中,URL 为: http://www.example.com/order
- 在荷兰语中URL 为: http://www.example.com/bestellen (“bestellen”是荷兰语“订单”的意思)
谢谢
In codeigniter, the name of your controller, reflects the URL.
But my question is, how can you create multi language URLs without copy/pasting all your controllers.
Example:
- In english the URL would be: http://www.example.com/order
- In dutch the URL would be: http://www.example.com/bestellen
("bestellen" is dutch for "order")
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 Code Igniter 用户指南中的 URI 路由。
Take a look at URI routing in Code Igniter's user guide.
通常使用URL重写过滤器来处理这种行为。
我不熟悉 CodeIgniter,但快速 Google 搜索会显示有关在 CodeIgniter 中使用 mod rewrite 的页面。
Usually a URL rewrite filter is used to handle this kind of behaviour.
I'm not familiar with CodeIgniter but a quick Google search shows this page about using mod rewrite in CodeIgniter.
您应该能够通过为每个控制器创建别名来做到这一点。检查你的 config/routes.php 路径
You should be able to do it by creating aliases to each controller. Check your config/routes.php path