ZF2 2个模块,每个模块带有路由器主机名


ZF2 2 modules each one with router hostname

我正在尝试设置一个有两个子域的应用程序,每个子域都有一个主机名路由和子路由,但没有成功。

有什么想法/例子吗?

感谢

您可以使用名为"Hostname"的特定路由器类型(类"Zend''Mvc''router''Http''Hostname")。这里有一个简单的例子:

'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',
                ),
            ),
        ),
    ),
),

我可能会把这个配置分成两部分,第一个模块的配置中有"example1",第二个模块的设置中有"sample2"。

您将在本页上找到有关该路由器类型和其他类型的完整信息。