[英]Zend2 - ZF2 - Routing Issue
我试图使我的路由器工作,以便:
/Auth redirects to Auth controller of Auth MOdule
/Auth/Login redirects to Login controller of Auth Module
虽然第一个方法正确,但/ Auth / Login会导致路由问题。
我的路由器配置文件如下所示:
'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')
),
),
),
),
),
),
答案在于@TimFountain他的评论。 由于您为子路由Auth/Login
命名,因此必须请求Auth/Auth/Login
才能获得匹配。
将子路线重命名为Login
您将按预期在Auth/Login
上获得路线匹配。
编辑此部分
'child_routes' => array(
'Auth_Login' => array(
// ... your existing codes
只需从Auth/Login
删除/
,然后使用连字符-
或_
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.