直接上代码
在bootstrap
中
public function _initRoute(Yaf_Dispatcher $dispatcher)
{
//在这里注册自己的路由协议,默认使用简单路由
//$route= new Base_route();
//$dispatcher->getRouter()->addRoute('myroute',$route);
$router = Yaf_Dispatcher::getInstance()->getRouter();
$route = new Yaf_Route_Rewrite(
'security/:ident/:rout',
array(
'controller' => 'Security',
'action' => 'html')
);
$router->addRoute('html1asdfd', $route);
}
在/application/controllers/Security.php的html方法如下
public function htmlAction($ident){
echo 'html action';
echo '<hr>';
var_dump($this->getRequest()->getParam('ident'));
var_dump($this->getRequest()->getParam('rout'));
结果