我需要在我的 ZF v.1.12 中创建一些自定义路由:
protected function _initRouter() {
$this->bootstrap('FrontController');
$this->bootstrap('locale');
$front = Zend_Controller_Front::getInstance ();
$router = $front->getRouter ();
$router->addRoute ( 'fastproduct', new Zend_Controller_Router_Route_Regex ( '(.+)\.html', array ('module' => 'default', 'controller' => 'products', 'action' => 'get' ), array (1 => 'q' ), '%s.html' ) );
$router->addRoute ( 'products', new Zend_Controller_Router_Route_Regex ( 'products/(.+)\.html', array ('module' => 'default', 'controller' => 'products', 'action' => 'get' ), array (1 => 'q' ), 'products/%s.html' ) );
$router->addRoute ( 'categories', new Zend_Controller_Router_Route_Regex ( 'categories/(.+)\.html', array ('module' => 'default', 'controller' => 'categories', 'action' => 'list' ), array (1 => 'q' ), 'categories/%s.html' ) );
$router->addRoute ( 'cms', new Zend_Controller_Router_Route_Regex ( 'cms/(.+)\.html', array ('module' => 'default', 'controller' => 'cms', 'action' => 'page' ), array (1 => 'url' ), 'cms/%s.html' ) );
$router->addRoute ( 'wiki', new Zend_Controller_Router_Route_Regex ( 'wiki/(.+)\.html', array ('module' => 'default', 'controller' => 'wiki', 'action' => 'help' ), array (1 => 'uri' ), 'wiki/%s.html' ) );
$router->addRoute ( 'tlds', new Zend_Controller_Router_Route_Regex ( 'tlds/(.+)\.html', array ('module' => 'default', 'controller' => 'tlds', 'action' => 'index' ), array (1 => 'uri' ), 'tlds/%s.html' ) );
return $router;
}
现在,如果我调用这些链接,也可以:
# http://www.mydomain.com/productname.html
# http://www.mydomain.com/products/productname.html
# http://www.mydomain.com/categories/hosting.html
# http://www.mydomain.com/cms/mypage.html
# http://www.mydomain.com/wiki/myhelp.html
# http://www.mydomain.com/tlds/com.html
# http://www.mydomain.com/admin/
但是我如何将语言添加到所有这些以下链接中?
# http://www.mydomain.com/it/productname.html
# http://www.mydomain.com/it/products/productname.html
# http://www.mydomain.com/it/categories/hosting.html
# http://www.mydomain.com/it/cms/mypage.html
# http://www.mydomain.com/it/wiki/myhelp.html
# http://www.mydomain.com/it/tlds/com.html
# http://www.mydomain.com/it/admin
感谢您的帮助。