Php 具有任意路径的zend路由器

Php 具有任意路径的zend路由器,php,zend-framework,url,redirect,Php,Zend Framework,Url,Redirect,所以我正在安装一个路由器 protected function _initRoutes(){ $front = Zend_Controller_Front::getInstance(); $router = $front->getRouter(); $routerInfo = array('action' => 'theaction', 'controller' => 'thecon

所以我正在安装一个路由器

  protected function _initRoutes(){
      $front = Zend_Controller_Front::getInstance();
      $router = $front->getRouter();
      $routerInfo =  array('action' => 'theaction',
                           'controller' => 'thecontroller',);
       $route = new Zend_Controller_Router_Route(
                         'some/path',
                         $routerInfo
       );
       $router->addRoute('some/path', $route);

      return $router;
  }
所以控制器“some”和动作“path”实际上并不存在。相反,当用户转到/some/path时,它应该重定向到'theaction/thecontroller'

我的问题是…我如何设置它,以便在/some/path之后接受任意数量的参数…例如,我希望/some/path/other/param也重定向到同一页…因此,只要路径的第一段是/some/path,不管接下来发生什么,我希望它们都重定向到同一控制器和操作


我知道你可以做
/some/path/*/*/*
…但只有当/some/path之后只有两个其他路径项时,这才有效…我希望这对任意数量的参数都有效…因此/some/path/param1/value1/param2/value2/param3/value3也应该有效,就像用户键入的一样控制器/Action/param1/value1/param2/value2/param3/Value3…

您只需使用一个星号,例如

$route = new Zend_Controller_Router_Route(
    'some/path/*',
    array(
        'action'     => 'theaction',
        'controller' => 'thecontroller',
        'module'     => 'default'
    )
);

// can't say for sure but a slash in the route name is probably a bad idea
// try a hyphen instead
$router->addRoute('some-path', $route);
请参见此处的第三个示例-

仅供参考,不要像在引导方法中那样获取
FrontController
资源。用这个代替

$this->bootstrap('FrontController');
$front = $this->getResource('FrontController');