When a certain domain is requested, I would like to display page genereted by defined controller / action. I tried using hostname route (in this case requesting http://www.some-page.de should dispatch transportAction in IndexController), like this:
$hostnameRoute = new Zend_Controller_Router_Route_Hostname(
'www.some-page.de',
array(
'controller' => 'index',
'action' => 'transport'
)
);
$plainPathRoute = new Zend_Controller_Router_Route_Static('');
$router->addRoute('transport', $hostnameRoute->chain($plainPathRoute));
Apparently I am doing something wrong, because it isn’t working (instead indexAction of IndexController is being dispatched). Any hints or ideas how can I achieve this?
I’ve got it – it’s very simple and I hope it is also good practice:
In a plugin’s routeShutdown hook I check the domain name (using $_SERVER[‘HTTP_HOST’]) and if it is the desired domain, I set the action name using following code: