您可以通过使用途径
在你的引导做这个做以下
protected function _initMyRoutes() {
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$router = $front->getRouter();
$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', APPLICATION_ENV);
$router->addDefaultRoutes();
$router->addConfig($config, 'routes');
return $router;
}
,并在configs目录下创建一个名为routes.ini,并在其中放置以下
routes.myRoute.type = "Zend_Controller_Router_Route_Static"
routes.myRoute.route = "/subaction/"
routes.myRoute.defaults.module = "mymodule"
routes.myRoute.defaults.controller = "index"
routes.myRoute.defaults.action = "subaction"
或
,你可以直接在你的引导与
protected function _initMyRoutes() {
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$router = $front->getRouter();
$router->addDefaultRoutes();
$route = new Zend_Controller_Router_Route_Static(
'subaction',
array('module' => 'mymodule', 'controller' => 'index', 'action' => 'subaction')
);
$router->addRoute('subaction', $route);
return $router;
}
添加路由应该做的伎俩,但使用的路线才能真正成为一个痛苦地劝。
More about routes in the ZF manual
在该控制器中创建另一个Acion函数 – Daya
@Daya我不想创建新的控制器或动作,只是我想缩短控制器动作的URL。 –