[英]Zend2 - ZF2 - Routing Issue
i am trying to make my router working so that: 我试图使我的路由器工作,以便:
/Auth redirects to Auth controller of Auth MOdule
/Auth/Login redirects to Login controller of Auth Module
While the first works just right the /Auth/Login results in routing issue. 虽然第一个方法正确,但/ Auth / Login会导致路由问题。
My router configuration file looks like below: 我的路由器配置文件如下所示:
'router' => array(
'routes' => array(
'Auth' => array(
'type' => 'literal',
'options' => array(
'route' => '/Auth',
'defaults' => array(
'controller' => 'Auth\Controller\Auth',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'Auth/Login' => array(
'type' => 'literal',
'options' => array(
'route' => '/Login',
'defaults' => array(
'controller' => 'Auth\Controller\Login',
'action' => 'index')
),
),
),
),
),
),
The answer lies in @TimFountain his comment. 答案在于@TimFountain他的评论。 Because you named the child route
Auth/Login
you will have to request Auth/Auth/Login
to get a match. 由于您为子路由
Auth/Login
命名,因此必须请求Auth/Auth/Login
才能获得匹配。
As soon as you rename the child route to Login
you will get the route match as expected on Auth/Login
. 将子路线重命名为
Login
您将按预期在Auth/Login
上获得路线匹配。
edit this section 编辑此部分
'child_routes' => array(
'Auth_Login' => array(
// ... your existing codes
Just remove /
from Auth/Login
and use hyphen -
or _
instead. 只需从
Auth/Login
删除/
,然后使用连字符-
或_
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.