【发布时间】:2014-03-06 12:28:11
【问题描述】:
阅读了大量关于路由的文章后,我仍然无法让它工作。
当我这样做时,我可以转到“/portal”:
'portal' => array(
'type' => 'Literal',
'options' => array(
'route' => '/portal',
'defaults' => array(
'controller' => 'Portal\Controller\Activities',
'action' => 'index',
),
),
),
但是当我像这样添加 child_routes 时:
'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'
),
),
),
),
),
我仍然可以转到“/portal”,但是当我转到“/portal/activities/index”(相同)时,我得到“找不到页面”。
希望有人能帮忙
提前致谢!
【问题讨论】:
-
你到底想做什么。从 url 参数创建一个匹配特定控制器和操作的路由?
-
我想创建一个带有模块和可选控制器和操作的路由。
标签: php routing zend-framework2