我正在将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不是我的核心甜点,我似乎无法找到确切的问题,有没有人能指出我正确的方向?
谢谢!
您可以简单地这样说>]
$ this-> redirect(array('controller'=>'admins','action'=>'dashboard'));
$this->redirect("YOUR URL");
example $this->redirect('/admins/dashboard');
您可以在Router :: url中使用'full_base'参数。例如
您可以简单地纠正此问题路由器:: connect('/',array('controller'=>'users','action'=>'index'));