I'm using a Hostname route to capture a subdomain and use as a category. I then chain a Router route for the controller, action and key/value pairs.
$hostnameRoute = new Zend_Controller_Router_Route_Hostname(
':customer.ddc.:domain',
array(
'customer' => ':customer'
)
);
$routerRoute = new Zend_Controller_Router_Route(
':controll开发者_StackOverflow社区er/:action/*',
array(
'controller' => 'index',
'action' => 'index'
)
);
$chainedRoute = $hostnameRoute->chain($routerRoute);
$frontController->getRouter()->addRoute('default',$chainedRoute);
I can capture everything except the key/value pairs on the URI. Adding them causes the Params object in the Request to not get populated.
This works: http://category.mydomain.com/controller/action/
This does not: http://category.mydomain.com/controller/action/username/frank
Thanks for any suggestions.
Try to use without /*
.
$routerRoute = new Zend_Controller_Router_Route(
':controller/:action',
array(
'controller' => 'index',
'action' => 'index'
)
);
as in 12.5.2. Using a Router is described.
The suggested patch didn't work for me. I adapted another patch found elsewhere on the ZF website and it seems to work well: http://pastie.org/1815135
There is indeed a bug which prevents wildcard matching when chaining routes. The comments in the bug description were very helpful in solving this issue with just a few lines of code change.
framework.zend.com/issues/browse/ZF-6654
精彩评论