路由输出错误

时间:2013-06-10 02:16:49

标签: php cakephp cakephp-2.1

我有以下(和唯一的)路由规则:

Router::connect(
    '/*',
    array(
        'controller' => 'dispatch',
        'action' => 'index'
    )
);

将所有请求发送到DispatchController::index(),这会响应解析和“重新路由”请求,就像动态路由一样。当我访问/sample-page/debug并对$this->request进行调试时,以下是我收到的输出:

object(CakeRequest) {
    params => array(
        'plugin' => null,
        'controller' => 'dispatch',
        'action' => 'index',
        'named' => array(),
        'pass' => array(
            (int) 0 => 'sample-page',
            (int) 1 => 'edit'
        )
    )
    [...]
}

我想从请求中收到正确的值:

object(CakeRequest) {
    params => array(
        'plugin' => null,
        'controller' => 'sample-page',
        'action' => 'edit',
        'named' => array(),
        'pass' => array()
    )
    [...]
}

我尝试过没有成功:

Router::connect(
    '/:controller/:action/*',
    array(
        'controller' => 'dispatch',
        'action' => 'index'
    )
);

0 个答案:

没有答案