After reading numerious articels about routing i'm still not able to get it to work.
When i do this i'm able to go to "/portal":
'portal' => array(
'type' => 'Literal',
'options' => array(
'route' => '/portal',
'defaults' => array(
'controller' => 'Portal\Controller\Activities',
'action' => 'index',
),
),
),
But When I add the child_routes like so:
'portal' => array(
'type' => 'Literal',
'options' => array(
'route' => '/portal',
'defaults' => array(
'controller' => 'Portal\Controller\Activities',
'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(
'__NAMESPACE__' => 'Portal\Controller',
'action' => 'index'
),
),
),
),
),
I'm still able to go to "/portal" but when I go to "/portal/activities/index" (which is the same) I get "Page could not be found".
Hope someone can help
Thanks in advance!
The segment definition is not correct, a / is missing, so complete child route is currently /portal[:controller[/:action]]
Change it to :
'portal' => array(
'type' => 'Literal',
'options' => array(
'route' => '/portal',
'defaults' => array(
'controller' => 'Portal\Controller\Activities',
'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(
'__NAMESPACE__' => 'Portal\Controller',
'action' => 'index'
),
),
),
),
),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.