phprouteszend-framework2zend-route

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.

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')
                    ),
                ),
            ),
         ),
     ),
 ),

Solution

  • edit this section

       'child_routes' => array(
            'Auth_Login' => array(
               // ... your existing codes 
    

    Just remove / from Auth/Login and use hyphen - or _ instead.