使用多语言codeigniter无法摆脱URL中的默认控制器

时间:2013-07-15 09:54:10

标签: php codeigniter internationalization routes multilingual

当我登陆我的主页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";

1 个答案:

答案 0 :(得分:0)

这是关于你的config / route.php文件。您可以根据需要更新路线。