直接上代码
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'));

结果
图片描述

鸟哥的文档真心不错


牙小木木
1.5k 声望80 粉丝

iamtb.cn


引用和评论

0 条评论