0
我有2個域,我想配置這樣一種方式,每個模塊路由到我的域。如何將Zend Framework 2的每個模塊配置爲每個主機名?
例如
1. domain1 module = domain1.ashwin.com
2. domain2 module = domain2.ashwin.com
我已經以下代碼:
module.config.php爲domain1的模塊
return array(
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'domain1.ashwin.com',
'defaults' => array(
'controller' => 'Domain1\Controller\Index',
'action' => 'index',
),
),
),
'home' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'__NAMESPACE__' => 'Domain1\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
)
module.config.php爲域2模塊
return array(
'router' => array(
'routes' => array(
'domain2' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'domain2.ashwin.com',
'defaults' => array(
'controller' => 'Domain2\Controller\Index',
'action' => 'index',
),
),
),
'home' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'__NAMESPACE__' => 'Domain2\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
),
)