我正在尝试在zend中设置到同一个控制器的多条路由,如下所示:
URL | Controller::Action
=================================================================================
http://mysite/tasks/:level/ | Objectives::Objectives
http://mysite/tasks/:level/:objective/ | Objectives::tasks
http://mysite/tasks/:level/:objective/:taskID/ | Objectives::view
我尝试了以下方法:
<?php
$router->addRoute('objectives', new Zend_Controller_Router_Route(
'task/:level/:objective/:taskID/',
array(
'controller' => 'objectives',
'action' => 'view'
)
));
$router->addRoute('objectives', new Zend_Controller_Router_Route(
'task/:level/:objective/',
array(
'controller' => 'objectives',
'action' => 'tasks'
)
));
$router->addRoute('objectives', new Zend_Controller_Router_Route(
'task/:level/',
array(
'controller' => 'objectives',
'action' => 'tasks'
)
));
?>
然而,最后一条规则似乎覆盖了路由器中以前的规则。我一遍又一遍地阅读了路由器的 Zend 文档,我觉得我只是错过了一些东西——我应该使用不同的路由器类吗?
任何帮助深表感谢