views:

207

answers:

2

Hello, 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(
 ':controller/: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.

+1  A: 

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.

hsz
Thank you for the response. Removing the * did not help. 12.5.7. Route Types discusses adding the * to match trailing key/value pairs in the URI. However, it appears it's only capturing a single key. Any attempt to add more, and the Params in the request object do not get populated at all.
BillA
It is a bid weird. Right now `http://category.mydomain.com/controller/action/username/frank` is redirecting you to which `controller`, `action`, etc ?
hsz
It doesn't redirect anywhere. The mappings for the routes are completely gone. I think I've hunted this down as a bug in ZF:http://framework.zend.com/issues/browse/ZF-6654
BillA
A: 

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

BillA