路由子目录

时间:2011-08-08 14:31:54

标签: routes kohana-3

在Kohana 3.2中如何建立一条接受多个目录的路线,即

http://example.com/foo/bar/controller/action/id

它也应该接受:

http://example.com/foo/controller/action/id
http://example.com/foo/bar/baz/controller/action/id

由于

1 个答案:

答案 0 :(得分:0)

Route::set('foo', 'foo(/<controller>(/<action>(/<id>)))')
    ->defaults(array(
            'directory'  => 'foo',
            'controller' => 'index',
    ));

Route::set('foobar', 'foo/bar(/<controller>(/<action>(/<id>)))')
    ->defaults(array(
            'directory'  => 'foo/bar',
            'controller' => 'index',
    ));

......或......

Route::set('directory', '<directory>(/<controller>(/<action>(/<id>)))',
    array(
        'directory' => '.*',
    ))
    ->defaults(array(
        'controller' => 'index',
    ));