Cakephp路线和一般路由 [英] Cakephp Routes And General Routing
本文介绍了Cakephp路线和一般路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个控制器与一个动作和一个变量,如下:
I have a controller with an action and a variable like this:
class AccountsController extends AppController
{
function profile($username = null)
{
}
}
此网页的网址是:
[domain]/accounts/profile/[username]
如何创建:
[domain]/[username]
?
推荐答案
尝试:
//in your routes.php file
Router::connect('/:username',
array('controller' => 'accounts', 'action' => 'profile'),
array(
'pass' => array('username')
)
);
希望它有帮助
这篇关于Cakephp路线和一般路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文