Routing ZF2路由混乱
我相信这个问题的答案是显而易见的,但我现在还没有找到答案。我的module.config.php中有以下代码Routing ZF2路由混乱,routing,zend-framework2,hostname,Routing,Zend Framework2,Hostname,我相信这个问题的答案是显而易见的,但我现在还没有找到答案。我的module.config.php中有以下代码 'subdomain' => array( 'type' => 'Hostname', 'options'=> array( 'route' => ':subdomain.mydomain.com', 'defaults' => array( 'controller' => 'Ap
'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(),
),
),
如果我删除
子路由,test.mydomain.com
匹配没有问题。当我添加child\u routes
部分时,test.mydomain.com/Index/foo
匹配,但test.mydomain.com
不匹配。我认为/:controller/:action
周围的方括号将使这些参数成为可选参数。我在这里误解了什么?好的,找到了解决方案,不知道为什么,但将斜线从:控制器移到paran's之外会使一切正常 您在module.php invokables中注册了控制器吗?好的,找到了解决方案,不确定为什么,但是将斜杠从:controller移到paran之外可以使一切正常工作。