我想使用 Zend Route 来处理 URI,例如 http:/US.video.yahoo.com 和http://video.yahoo.com具有相同的路由。对于第二个命题,我希望系统告诉我在第一个命题中是“美国”的国家现在为 NULL。
但是我没有到达 Zend Route Hostname 做正则表达式之类的东西。
我怎么能那样做?
我想使用 Zend Route 来处理 URI,例如 http:/US.video.yahoo.com 和http://video.yahoo.com具有相同的路由。对于第二个命题,我希望系统告诉我在第一个命题中是“美国”的国家现在为 NULL。
但是我没有到达 Zend Route Hostname 做正则表达式之类的东西。
我怎么能那样做?
要在主机名上实现路由,您需要 Zend_Controller_Router_Route_Hostname
$hostnameRoute = new Zend_Controller_Router_Route_Hostname(
':country.:controller.yahoo.com',
array( 'action' => 'index' )
);
要将您的主机名路由组合到其他路由,您需要 Zend_Controller_Router_Route_Chain
$staticRoute = new Zend_Controller_Router_Route_Static('');
$router->addRoute('default', $hostnameRoute->chain($staticRoute));
查看 Zend 框架手册,有一些很好的示例供您学习。