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
精彩评论