简体   繁体   English

添加Zend_Controller_Router_Route替换默认路由

[英]Add Zend_Controller_Router_Route replaced default route

When I added this route 当我添加这条路线时

$classes_router = new Zend_Controller_Router_Route(
    '/:filter1/:filter2/*',
    array(
        'module'     => 'course',
        'controller' => $filter_controller,
        'action'     => 'index',
        'filter1'    => '',
        'filter2'    => ''
    )
);

Te default route :module/:controller/:action doesn't work anymore. 默认路由:module/:controller/:action不再起作用。 Please tell me what is the problem? 请告诉我有什么问题?

The problem is that a request to somemodule/somecontroller/someaction will be matched by the route you've added (which will be checked before the default one). 问题是对somemodule/somecontroller/someaction的请求将与您添加的路由匹配(将在默认路由之前进行检查)。 You need to provide some restriction in the route to determine what it matches, perhaps by limiting the possible matches for the :filter1 variable: 您需要在路由中提供一些限制以确定它匹配的内容,可能通过限制:filter1变量的可能匹配:

$classes_router = new Zend_Controller_Router_Route(
    '/:filter1/:filter2/*',
    array(
        'module'     => 'course',
        'controller' => $filter_controller,
        'action'     => 'index',
        'filter1'    => '',
        'filter2'    => ''
    ), array(
        'filter1' => '(value1|foo|somethingelse)'
    )
);

or adding a static prefix: 或添加静态前缀:

$classes_router = new Zend_Controller_Router_Route(
    '/filter/:filter1/:filter2/*',
    array(
        'module'     => 'course',
        'controller' => $filter_controller,
        'action'     => 'index',
        'filter1'    => '',
        'filter2'    => ''
    )
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM