我正在更改我的应用程序路由,以便我可以使用带有gTLD(example.com/de/)的子目录而不是URL params(example.com?loc=de)。由于它在http://devzone.zend.com/1765/chaining-language-with-default-route/中,我使用了以下路由配置:
protected function _initRoutes() {
$locale = $this->getResource('locale');
// Create route with language id (lang)
$routeLang = new Zend_Controller_Router_Route(
':lang', array(
'lang' => $locale->getLanguage()
), array('lang' => '[a-z]{2}')
);
// Now get router from front controller
$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
// Instantiate default module route
$routeDefault = new Zend_Controller_Router_Route_Module(
array(), $front->getDispatcher(), $front->getRequest()
);
// Chain it with language route
$routeLangDefault = $routeLang->chain($routeDefault);
// Add both language route chained with default route and
// plain language route
$router->addRoute('default', $routeLangDefault);
$router->addRoute('lang', $routeLang);
// Register plugin to handle language changes
$front->registerPlugin(new Sistema_Plugin_Language());
}
我将baseUrl用于整个网站链接。
然而,我的旧链接(example.com/news/)会返回错误消息"没有符合请求的路由",我如何强制用户或将用户重定向到新网址(example.com/烯/消息/)?