I have just started learning ZF2, so I apologize if the question is trivial. What I want to achieve is to redirect the user from projectname.loc:8888/user to projectname.loc:8888/user/login If I enter projectname.loc:8888/user/login manually the form is displayed without any issues. If I enter projectname.loc:8888/user then I get the following error message: Route with name "login" not found.
The route setting is modul.config.php are:
'user' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user',
'defaults' => array(
'__NAMESPACE__' => 'TAuth\Controller',
'controller' => 'User',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'process' => 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(
),
),
),
),
),
UserController.php:
public function indexAction() {
return $this->redirect()->toRoute('user/login', array('controller'=>'user', 'action'=>'login'));
}
public function loginAction() {
$form = new Login();
return ['form' => $form];
}
I have a feeling that I have the wrong child_routes configuration but I cannot figure out the proper solution... :(
Any help is much appreciated!