开发者

Syntax for Zend_Controller_Router_Route with infinite parameters?

I need a Zend_Controller_Route_Route with controller => 'downloads', action => 'index' and a parameter variable which is infinite.

w开发者_运维技巧ww.domain.com/downloads/this/is/the/path/to/the/folder 

should redirect to

DownloadsController > indexAction

I was thinking about something like the following:

'downloads' => array(
        'route' => 'downloads/*',
        'defaults' => array('controller' => 'downloads', 'action' => 'index')

But how do I request the * as a parameter?


You can use a RegEx Route http://framework.zend.com/manual/de/zend.controller.router.html#zend.controller.router.routes.regex

$router = Zend_Controller_Front::getInstance()->getRouter(); // returns a rewrite router by default

$route['default'] = new Zend_Controller_Router_Route_Regex(
    '/downloads/(.*)',
    array(
        'controller'=> 'Downloads',
        'action'    => 'index',
    ),
    array(
        1           => 'downloadpath',
    )
);

$router->addRoute('default', $route['default']);

I havent tested it but something like that shoudl work

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜