yaf框架访问路由为什么始终访问INDEX下的INDEX控制器下的INDEX方法

1.最近学习yaf 看到手册上说默认路由方式,一系列安装后,输入网址显示Hello World! I am Stranger这是正常的!

2.但是我在controlers下面的Index.php文件里面新建public function testAction方法,路由访问http://sitename/Index/Index/test,始终访问的是indexAction方法的内容!

3.求大神指导!(另:如果我想把控制器分类,例如目录是controllers/son/son.php,这个文件中的控制器继承controllers/father.php这种目录格式我应该怎么设置路由?)

4.下面附上目录和各种配置!


Nginx 配置

        location / {
                try_files $uri $uri/ /index.php;

                if (!-e $request_filename) {
                        rewrite ^(.*)$ /index.php?s=$1 last;
                        break;
               }
               #手册配置 并不管用
            #    if (!-e $request_filename) {
            #        rewrite ^/(.*) /index.php/$1 last;
            #    }
        }

Index控制器

<?php
/**
 * @name IndexController
 * @author root
 * @desc 默认控制器
 * @see http://www.php.net/manual/en/class.yaf-controller-abstract.php
 */
class IndexController extends Yaf_Controller_Abstract {

    /** 
     * 默认动作
     * Yaf支持直接把Yaf_Request_Abstract::getParam()得到的同名参数作为Action的形参
     * 对于如下的例子, 当访问http://yourhost/demo/index/index/index/name/root 的时候, 你就会发现不同
     */
    public function indexAction($name = "Stranger") {
        //1. fetch query
        $get = $this->getRequest()->getQuery("get", "default value");

        //2. fetch model
        $model = new SampleModel();

        //3. assign
        $this->getView()->assign("content", $model->selectSample());
        $this->getView()->assign("name", $name);

        //4. render by Yaf, 如果这里返回FALSE, Yaf将不会调用自动视图引擎Render模板
        return TRUE;
    }

    public function testAction()
    {
        echo "this is a test of router";
    }
}

求各位大佬答疑解惑!

繁华开满天机
浏览 962回答 3
3回答

暮色呼如

已解决,yaf不支持PATH_INFO模式,在路由重写之后,关闭掉PATH_INFO模式即可

MMTTMM

location / { if (!-e $request_filename) { rewrite ^(.*) /index.php/$1 last; } } 试试这样行不行。

浮云间

你为何有这么奇怪的想法?控制器还带继承的?
打开App,查看更多内容
随时随地看视频慕课网APP