404 error, Zend Framework 2 The requested URL could not be matched by routing -
a 404 error occurred page not found. requested url not matched routing.
my module.config.php file :
'router' => array( 'router' => array( 'test' => array( 'type' => 'segment', 'options' => array( //http://localhost/test/test 'route' => '/test[/[:action]]', 'constraints' => array( 'action' => '[a-za-z][a-za-z0-9_-]*', ), 'defaults' => array( 'controller' => 'test\controller\test', 'action' => 'test' ), ), ), ), ),
help please, new in zend framework 2 !
you should utilize configuration application module in zendskeletonapplication:
'router' => array( 'routes' => array( 'test' => array( 'type' => 'literal', 'options' => array( 'route' => '/book', 'defaults' => array( '__namespace__' => 'test\controller', 'controller' => 'test', 'action' => 'index', ), ), 'may_terminate' => true, 'child_routes' => array( 'default' => 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( ), ), ), ), ), ), ),
you add together next code:
'test' => array( 'type' => 'segment', 'options' => array( 'route' => '[/:action][/:id]', 'constraints' => array( 'action' => '[a-za-z][a-za-z0-9_-]*', 'id' => '[0-9]*', ), 'defaults' => array( '__namespace__' => 'test\controller', 'controller' => 'test', 'action' => 'index', ), ), ),
add code 'child-routes' key , after you'll access url: localhost/:controller_name/:action_name/:id (example : http://zf.dev/test/index or http://zf.dev/test/add/1). , it's work! code can prepare error 404 tutorial in zf2 documentation.
zend-framework2
No comments:
Post a Comment