[英]ZF2 2 modules each one with router hostname
I'm trying to setup an app with 2 subdomains, each one with a hostname route and child routes but with no luck. 我正在尝试设置一个带有2个子域的应用程序,每个子域都有一个主机名路由和子路由,但没有运气。
Any idea / example? 任何想法/例子?
Thanks 谢谢
You can use a specific router type named "Hostname" (class "Zend\\Mvc\\Router\\Http\\Hostname"). 您可以使用名为“Hostname”的特定路由器类型(类“Zend \\ Mvc \\ Router \\ Http \\ Hostname”)。 Here is a simple example : 这是一个简单的例子:
'router' => array(
'routes' => array(
'example1' => array(
'type' => 'Hostname',
'options' => array(
'route' => ':subdomain.mydomain.com',
'constraints' => array(
'subdomain' => 'mysubdomain1',
),
'defaults' => array(
'controller' => 'MyModule1\Controller\MyFirstController',
'action' => 'index',
),
),
),
'example2' => array(
'type' => 'Hostname',
'options' => array(
'route' => ':subdomain.mydomain.com',
'constraints' => array(
'subdomain' => 'mysubdomain2',
),
'defaults' => array(
'controller' => 'MyModule2\Controller\MySecondController',
'action' => 'index',
),
),
),
),
),
I would probably split this configuration into two parts, with "example1" in the configuration of my first module and "example2" in the configuration of my second module. 我可能会将此配置分为两部分,第一个模块的配置中包含“example1”,第二个模块的配置中包含“example2”。
You will find a complete information about that router type and others on this page . 您将在此页面上找到有关该路由器类型和其他类型的完整信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.