I'm trying to setup an app with 2 subdomains, each one with a hostname route and child routes but with no luck.
Any idea / example?
Thanks
You can use a specific router type named "Hostname" (class "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.
You will find a complete information about that router type and others on this page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With