Zend framework Zend Route:如果链接以/something开头,则忽略其他规则
我有两个模块,基本上应该超越其他URL /管理/类别/编辑/id/1(编辑类别页面) /管理/类别/索引(管理模块中类别的索引页) /管理/类别(管理模块中类别的索引页) /女性喜欢男性/类别(URL路由自/default/category/view/id/women like men) 上述规定如下:Zend framework Zend Route:如果链接以/something开头,则忽略其他规则,zend-framework,zend-route,Zend Framework,Zend Route,我有两个模块,基本上应该超越其他URL /管理/类别/编辑/id/1(编辑类别页面) /管理/类别/索引(管理模块中类别的索引页) /管理/类别(管理模块中类别的索引页) /女性喜欢男性/类别(URL路由自/default/category/view/id/women like men) 上述规定如下: $router->addRoute('view-category', new Zend_Controller_Router_Route(':id/category/:pa
$router->addRoute('view-category', new Zend_Controller_Router_Route(':id/category/:page', array('module' => 'default', 'controller' => 'category', 'action' => 'view', 'page' => null)));
$router->addRoute('management/category', new Zend_Controller_Router_Route('management/category/', array('module' => 'management', 'controller' => 'category', 'action' => 'index')));
有很多类似的页面像这样“冲突”(画廊、电影、用户)等等
我真正想要的是一条规则,上面写着/management/*路由到模块管理/controller/action,而忽略下面的规则,任何与/management有关的内容都可以。不管怎样,被称为管理的用户/画廊/电影/类别的可能性很低
可能吗
编辑,我已经做了如下:
$router->addRoute('administration', new Zend_Controller_Router_Route_Regex('management/?(.*)/?(.*)', array('module' => 'management'), array(1 => 'controller', 2 => 'action')));
/管理/分类工作正常,但之后的任何结果都会导致404,这应该很简单。定义路由的顺序很重要-它们以相反的顺序进行检查,因此为了让管理规则“覆盖”其他规则,您希望最后定义它(即,在所有其他路由之后)。类似这样的东西(基本上就是你所拥有的)应该会起作用:
$route = new Zend_Controller_Router_Route(
'management/:controller/:action/*',
array(
'module' => 'management'
'controller' => 'index',
'action' => 'index'
)
);
$router->addRoute('management', $route);
如果在此之后,您的任何管理URL仍处于404'ing状态,那么它们与该路由不匹配,因此需要调整,或者您需要一些其他管理路由来匹配其他情况