protected function _initHostnameRouter()
{
$this->bootstrap('autoload');
$this->bootstrap('FrontController');
$front = $this->getResource('FrontController');
$router = $front->getRouter();
$hostRoute1 = new Zend_Controller_Router_Route_Hostname('admin.example.net',array('module' => 'admin'));
$hostRoute2 = new Zend_Controller_Router_Route_Hostname('vouchers.example.net',array('module' => 'vouchers'));
$pathRoute = new Curo_Route_NoModule();
$router->removeDefaultRoutes();
$router->addRoute('default', $pathRoute);
$router->addRoute('admin', $hostRoute1->chain($pathRoute));
$router->addRoute('vouchers', $hostRoute2->chain($pathRoute));
}
I have the above code used in Bootstrap file and it is working good. I need to add another domain name for admin module. Now I am using admin.example.net
for admin module. I also need to add admin.examplenew.net
. I don't need to change the old domain. Both should be working at the same time.
I have tried,
$hostRoute1 = new Zend_Controller_Router_Route_Hostname('admin.example.net',array('module' => 'admin'));
$hostRoute2 = new Zend_Controller_Router_Route_Hostname('vouchers.example.net',array('module' => 'vouchers'));
$hostRoute3 = new Zend_Controller_Router_Route_Hostname('admin.examplenew.net',array('module' => 'adminnew'));
$pathRoute = new Curo_Route_NoModule();
$router->removeDefaultRoutes();
$router->addRoute('default', $pathRoute);
$router->addRoute('admin', $hostRoute1->chain($pathRoute));
$router->addRoute('vouchers', $hostRoute2->chain($pathRoute));
$router->addRoute('adminnew', $hostRoute3->chain($pathRoute));
But both domain names are not working at the same time.
You are adding $hostRoute1
and $hostRoute3
to the $router
under the same name: admin
. So the second assignment is overriding the first.
Make the keys unique - by, say, changing the last one to adminnew
- and you should be good.