我有一个带有动作和变量的控制器:
class AccountsController extends AppController
{
function profile($username = null)
{
}
}
此页面的网址为:
[domain]/accounts/profile/[username]
我该如何制作:
[domain]/[username]
答案 0 :(得分:1)
尝试:
//in your routes.php file
Router::connect('/:username',
array('controller' => 'accounts', 'action' => 'profile'),
array(
'pass' => array('username')
)
);
希望有所帮助