[英]ZF2 Child routes not working
After reading numerious articels about routing i'm still not able to get it to work. 在阅读了有关路由的大量文章之后,我仍然无法使其工作。
When i do this i'm able to go to "/portal": 当我这样做时,我可以转到“ /门户”:
'portal' => array(
'type' => 'Literal',
'options' => array(
'route' => '/portal',
'defaults' => array(
'controller' => 'Portal\Controller\Activities',
'action' => 'index',
),
),
),
But When I add the child_routes like so: 但是当我像这样添加child_routes时:
'portal' => array(
'type' => 'Literal',
'options' => array(
'route' => '/portal',
'defaults' => array(
'controller' => 'Portal\Controller\Activities',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => 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(
'__NAMESPACE__' => 'Portal\Controller',
'action' => 'index'
),
),
),
),
),
I'm still able to go to "/portal" but when I go to "/portal/activities/index" (which is the same) I get "Page could not be found". 我仍然能够转到“ / portal”,但是当我转到“ / portal / activities / index”(相同)时,我得到“找不到页面”。
Hope someone can help 希望有人能帮忙
Thanks in advance! 提前致谢!
The segment definition is not correct, a / is missing, so complete child route is currently /portal[:controller[/:action]] 段定义不正确,缺少/,因此当前完整的子路由为/ portal [:controller [/:action]]
Change it to : 将其更改为:
'portal' => array(
'type' => 'Literal',
'options' => array(
'route' => '/portal',
'defaults' => array(
'controller' => 'Portal\Controller\Activities',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => 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(
'__NAMESPACE__' => 'Portal\Controller',
'action' => 'index'
),
),
),
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.