我想要实现的是我只能更改 url 中的语言前缀,但是遇到问题......有我的路线:
$lang_regexp = implode('|', Configure::read('Config.languages'));
Router::connect('/', array('controller' => 'languages', 'action' => 'choose'));
Router::connect('/:lang/:controller/:action/*',
array(),
array('lang' => $lang_regexp));
// actual default page; can be any controller
Router::connect('/:lang/pages/ajax_newsletter', array('controller' => 'pages', 'action' => 'ajax_newsletter'));
Router::connect('/:lang/',
array('controller' => 'pages', 'action' => 'index', 'home'),
array('lang' => $lang_regexp));
Router::connect('/:lang/:slug', array('controller' => 'pages', 'action' => 'pages'), array('lang' => $lang_regexp));
Router::connect('/:slug', array('controller' => 'pages', 'action' => 'pages'), array('lang' => $lang_regexp));
Router::connect('/:lang/special_offers', array('controller' => 'pages', 'action' => 'offers'));
Router::connect('/:lang/special_offers/*', array('controller' => 'pages', 'action' => 'offers_city'));
Router::connect('/:lang/news/*', array('controller' => 'pages', 'action' => 'news_article'));
Router::connect('/:lang/news', array('controller' => 'pages', 'action' => 'news'));
Router::connect('/:lang/:slug/:id/*', array('controller' => 'pages', 'action' => 'offers'), array('lang' => $lang_regexp));
Router::connect('/cities/select', array('controller' => 'cities', 'action' => 'select'));
Router::connect('/cities/select/*', array('controller' => 'cities', 'action' => 'select'));
我的语言切换器:
$this->html->link($this->html->image('flag_ru.gif', array("alt"=>"", "width"=>"14px", "height"=>"12px", "title"=>"")), array("lang" => "rus"), array('escape' => false));
:lang/:slug
是菜单条目,所以如果我localhost/eng/contact
在语言更改后有菜单,我会得到localhost/rus/pages/pages
......如何只更改语言前缀?