【问题标题】:Cannot get rid of default controller in URL with multilingual codeigniter无法使用多语言 codeigniter 摆脱 URL 中的默认控制器
【发布时间】:2013-07-13 03:35:38
【问题描述】:

当我登陆我的主页 www.domain.com(使用默认控制器“home”)时,浏览器会重定向到 www.domain.com/en/home。我希望看到的是 www.domain.com/en(我认为 Google 会将这些页面视为重复内容?)

是否可以将默认控制器排除在 URL 之外,以便只有语言跟随域,即 www.domain.com/en?

下面是我的代码:

$route['default_controller'] = "Home";
$route['404_override'] = '';

// '/en', '/es' URIs -> use default controller
$route['^(en|es)$'] = 'home'; //$route['default_controller']; //'home'



// route es translation of girls to girls
$route['es/chicas'] = "girls";
$route['es/chicas/chica/(:num)/(:any)'] = "girls/girl/$1/$2";
$route['es/chicas/etiquetas/(:num)/(:any)'] = "girls/tags/$1/$2";

// movies es routes
$route['es/peliculas'] = "movies";
$route['es/peliculas/pelicula/(:num)/(:any)'] = "movies/movie/$1/$2";
$route['es/fotos/galeria/pelicula/(:num)/(:any)'] = 'photos/gallery/movie/$1/$2';
$route['es/peliculas/etiquetas/(:num)/(:any)'] = "movies/tags/$1/$2";

$route['es/unirse'] = "join";

// general catch all for anything that doesn't fit rules above, but doesn't have a 
// language prefix e.g. en/girls -> girls controller
$route['^(en|es)/(.+)$'] = "$2";

【问题讨论】:

  • 你能告诉我,你是如何实现这个网址 www.domain.com/en/home.
  • 是的,对不起,我本来应该发布代码的。我没有修改我的原始帖子以包含代码。
  • 试着把 $route['^(en|es)$'] = 'home';之前 $route['default_controller'] = "Home";我认为 $route['default_controller'] = "Home";不需要,因为您已经在 $route['^(en|es)$'] = 'home';还要对 base_url 的配置文件进行更改。尝试将默认的 es 或 en 放在 url 中。
  • 你得到答案了吗?

标签: php codeigniter internationalization routes multilingual


【解决方案1】:

这与您的 config/route.php 文件有关。准确地更新您的路线。

【讨论】:

  • 我现在已经在我的原始帖子中包含了我的路线文件。
猜你喜欢
  • 2018-05-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-30
相关资源
最近更新 更多