簡體   English   中英

Zend2-ZF2-路由問題

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM