単一のホスト名のルートに複数のサブドメインを一致させることはできません。だからここにあなたがしなければならないものです:
$hostnameRoutes = array(
new Zend_Controller_Router_Route_Hostname('example.com', array('controller' => 'events', 'event-id' => $eventId)),
new Zend_Controller_Router_Route_Hostname(':subdomain.example.com', array('controller' => 'events', 'event-id' => $eventId)),
new Zend_Controller_Router_Route_Hostname(':sandbox.dev.example.com', array('controller' => 'events', 'event-id' => $eventId))
);
$homepageRoute = new Zend_Controller_Router_Route_Static('', array('action' => 'overview'));
$eventPagesRoute = new Zend_Controller_Router_Route(':action/*', array('action' => 'overview'));
$staticEventPagesRoute = new Zend_Controller_Router_Route('page/:page-id', array('action' => 'static-page'));
foreach ($hostnameRoutes as $i => $hostnameRoute) {
$router->addRoute('sports_homepage' . $i, $hostnameRoute->chain($homepageRoute));
$router->addRoute('sports_event_pages' . $i, $hostnameRoute->chain($eventPagesRoute));
$router->addRoute('sports_static_event_Page' . $i, $hostnameRoute->chain($staticEventPagesRoute));
}
注:ルートの名前は($i
に注意し、それらを一意にするために連結されている)一意であることを確認してください。私はそれを初めて忘れてしまい、なぜそれが機能していないのか理解できませんでした。