【问题标题】:codeigniter url routing not working when doing with multiple language使用多种语言时,codeigniter url路由不起作用
【发布时间】:2020-03-04 22:45:15
【问题描述】:

在 codeigniter 中,我使用 routes.php 中的以下代码将我的 url www.xxxxxx.com/jewels 路由到 www.xxxxxx.com/luxury-jewels

$route['(.*)luxury-jewels'] = "jewels";

当我是我的其他语言时,上面的代码适用于英语,它在 URL 中添加新参数 "ru" 例如:

www.xxxxxx.com/ru/luxury-jewels 执行此操作时出现 404 Page Not Found 错误。

我尝试了不同的路由组合,但它不起作用。

【问题讨论】:

    标签: php codeigniter url


    【解决方案1】:

    使用目的

    $route['(.*)luxury-jewels'] = "jewels";
    

    使用

    $route['(:any)/luxury-jewels'] = "jewels";
    

    经过测试并为我工作。

    【讨论】:

    • 当我删除此代码时 $route['^(en|ru)/(.+)$'] = "$2";它的工作,但其他页面不工作
    • 而不是 $route['^(en|ru)/(.+)$'] = "$2";使用 $route['^(:any)/(.+)$'] = "$2";
    • $route['^(:any)/(.+)$'] = "$2";当我改变这个也不起作用..语言更改控制器没有改变
    • 您使用哪个函数来更改语言?可以分享一下吗?
    • 我已经解决了有一个位置问题...非常感谢你
    【解决方案2】:

    您需要为其添加另一条路线。

    例如

    $route['ru/luxury-jewels'] = "jewels";
    

    或 适用于多种语言

    $route['(:any)/luxury-jewels'] = "jewels";
    

    【讨论】:

      猜你喜欢
      • 2020-03-09
      • 2012-05-08
      • 2013-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-09
      • 1970-01-01
      • 2011-11-07
      相关资源
      最近更新 更多