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));
}
我在 Bootstrap 文件中使用了上述代码,它运行良好。我需要为管理模块添加另一个域名。现在我正在使用admin.example.net
管理模块。我还需要添加admin.examplenew.net
. 我不需要更改旧域。两者应该同时工作。
我试过了,
$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));
但是两个域名不能同时工作。