Php – key value routing in Zend Framework Route

hostnamephprouterrouteszend-framework

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.

Best Solution

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.

Related Question