CakePHP Router :: url无法正常工作

问题描述 投票:2回答:4

我正在将CakePHP 2.0用于网站的一小部分管理。如果用户正确登录,我会将他们重定向到管理员仪表板。我这样做如下:

$this->redirect(Router::url(array('controller' => 'admin', 'action' => 'dashboard')));

重定向正确完成,但是由于某种原因,重定向到的URL无法正确构建。 URL具有以下结构(请注意URL中的双[root]部分-这是错误的):

http://localhost/[root]/[root]/admin/dashboard

当然,它们会显示错误,因为此控制器/动作不存在。该网址应为以下格式:

http://localhost/[root]/admin/dashboard

由于cakePHP不是我的核心甜点,我似乎无法找到确切的问题,有没有人能指出我正确的方向?

谢谢!

php routing cakephp-2.0
4个回答
0
投票

您可以简单地这样说>]

$ this-> redirect(array('controller'=>'admins','action'=>'dashboard'));


0
投票
$this->redirect("YOUR URL");

example $this->redirect('/admins/dashboard');

0
投票

您可以在Router :: url中使用'full_base'参数。例如


0
投票

您可以简单地纠正此问题路由器:: connect('/',array('controller'=>'users','action'=>'index'));

© www.soinside.com 2019 - 2024. All rights reserved.