【发布时间】:2014-10-08 11:54:20
【问题描述】:
我正在使用 zend 框架 2。我想在站点的根目录上放置几个页面。即
www.exampleSite.com/siteMap
我知道如何获取子目录中的页面。
即
www.exampleSite.com/support/helppage
'router' => array(
'routes' => array(
'supportsec' => array(
'type' => 'segment',
'options' => array(
'route' => '/support[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'support\Controller\supportController',
'action' => 'index',
),
),
), ), ),
我也知道如何路由到主页,即
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Members\Controller\HomeController',
'action' => 'index',
),
),
),
困惑在于如何将其他页面放置在网站的根目录中。
提前感谢您的帮助
我听从了@exlord 的建议,并将它放在我的模块中。
'my-static-page-1' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/my-static-page-1',
'defaults' => array(
'controller' => 'Members\Controller\HomeController',
'action' => 'my-static-page-1',
),
),
),
我现在可以拥有如下页面:
www.exampleSite.com/examplepage
但是路由只是将路由发送到索引
'成员\控制器\家庭控制器'
但是我需要将路由发送到示例页面的操作函数,即
examplepageAction(){
}
我需要做什么?
【问题讨论】:
-
您能否详细说明您对路由的困惑?您能否提供一些路由示例以更清楚地了解您的问题?