0

当我添加这条路线时

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

默认路由:module/:controller/:action不再起作用。请告诉我是什么问题?

4

1 回答 1

2

问题是请求somemodule/somecontroller/someaction将与您添加的路由匹配(将在默认路由之前检查)。您需要在路由中提供一些限制来确定它匹配的内容,也许是通过限制: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)'
    )
);

或添加静态前缀:

$classes_router = new Zend_Controller_Router_Route(
    '/filter/:filter1/:filter2/*',
    array(
        'module'     => 'course',
        'controller' => $filter_controller,
        'action'     => 'index',
        'filter1'    => '',
        'filter2'    => ''
    )
);
于 2012-10-22T16:16:25.287 回答