Okay, found the solution, not sure why, but moving the slash from :controller outside the paran's makes everything work fine.
ZF2 Routing Confusion
-
30-05-2022 - |
سؤال
I am sure the answer to this is obvious, but it is eluding me right now. I have the following code in my module.config.php
'subdomain' => array(
'type' => 'Hostname',
'options'=> array(
'route' => ':subdomain.mydomain.com',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'foo',
),
),
'child_routes' => array(
'withcontroller' => 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(),
),
),
If I remove the child_routes, test.mydomain.com
is matched no problem. When I add the child_routes
section, test.mydomain.com/Index/foo
is matched, but test.mydomain.com
is not matched. I thought that the square parentheses around /:controller/:action
would make those parameters optional. What am I misunderstanding here?
المحلول
لا تنتمي إلى StackOverflow