最快/最简单的方法:
// routes.php
Router::connect('/category/:category/:subcategory',
array('controller'=>'categories', 'action'=>'view'),
array('pass' => array('category', 'subcategory')));
// CategoryController/view
public function view($category = 'default', $subcategory = null) {
// your logic here
}
// links
$this->Html->link('View PHP >> Tutorials', array('action'=>'view',
'category'=>'php', 'subcategory'=>'tutorials'));
// output
<a href="/category/php/tutorials">View PHP >> Tutorials</a>
通过/category/在开始时引入,您不必担心为每个其他控制器/动作提供路由(否则每个请求都会发送到您的类别控制器。