Php 如何将Zend Framework 2每个模块配置为每个主机名?
我有2个域,我想配置这样一种方式,每个模块路由到我的域 e、 g 我有以下代码: domain1模块的module.config.php domain2模块的module.config.phpPhp 如何将Zend Framework 2每个模块配置为每个主机名?,php,zend-framework,routes,zend-framework2,Php,Zend Framework,Routes,Zend Framework2,我有2个域,我想配置这样一种方式,每个模块路由到我的域 e、 g 我有以下代码: domain1模块的module.config.php domain2模块的module.config.php 只要看看你的代码,你已经声明了三次路线“回家”。请记住,Zend时,这些路由实际上合并到了一个大数组中 启动你的模块 如果我们以domain1的module.config.php为例 你应该这样做 'routes' => array( 'domain1' => array(
只要看看你的代码,你已经声明了三次路线“回家”。请记住,Zend时,这些路由实际上合并到了一个大数组中 启动你的模块 如果我们以domain1的module.config.php为例 你应该这样做
'routes' => array(
'domain1' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'domain1.ashwin.com',
'defaults' => array(
'controller' => 'Domain1\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(
'__NAMESPACE__' => 'Domain1\Controller',
),
),
),
),
),
),
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(
),
),
),
),
),
),
),
)
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(
),
),
),
),
),
),
),
)
'routes' => array(
'domain1' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'domain1.ashwin.com',
'defaults' => array(
'controller' => 'Domain1\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(
'__NAMESPACE__' => 'Domain1\Controller',
),
),
),
),
),
),