4

我想使用这样的 URL:

site.com/car-list/param1/value1/param2/value2

“汽车”是可变的,可以是anytihng。我像这样解决了“site.com/car-list”部分:

    $categoryRoute = new Zend_Controller_Router_Route_Regex(
        '(\b.+\-list\b)',
        array(
            'module' => 'default',
            'controller' => 'search',
            'action' => 'index'
        ),
        array(
            1 => 'productType'
        )
    );

当我想要“productType”参数时,我可以获得“car-list”。但是我无法在控制器中使用 $this->_getParam() 获取其余的 url。

我怎样才能做到这一点?谢谢。

4

1 回答 1

5

Well, i don't see how to make it with Router_Route_Regex, but with Router_Route it would be easier (thought, i replace "-" with "/")

$categoryRoute = new Zend_Controller_Router_Route
    ':car/list/*',
    array(
        'module' => 'default',
        'controller' => 'search',
        'action' => 'index'
    )
);

magic happens due to the "/*" at the end of the string. :car variable can be got with $request->getParam('car');

于 2010-12-27T21:17:07.000 回答