0

我的项目文件夹是 demo,里面有文件夹 application、library 和 public。我的 index.php 在公用文件夹中。因此,我将浏览器指向 localhost/demo/public。在我的应用程序文件夹中,我有一个控制器文件夹,里面有我的 IndexController。在这个索引控制器中,我的 indexAction 方法是:

   $this->_redirect('/auth/login');
   $this->_helper->layout->disableLayout();
   $this->_helper->viewRenderer->setNoRender(true);

因此,在这种方法中,我想重定向到位于同一控制器目录中的 AuthController 到其操作登录。但浏览器呈现:

在此服务器上找不到请求的 URL /demo/public/auth/login。

AuthController 在控制器中,而不是在公共文件夹中。如何正确格式化 _redirect 调用中的 URL 字符串?

4

2 回答 2

0

尝试使用 url 视图助手,例如:

$this->_redirect($this->view->url(array('controller'=>'auth','action'=>'login');

另一种选择是尝试绝对格式化您的 URL,例如:

$this->_redirect($_SERVER['HTTP_ROOT'].'/auth/login')

虽然第一种选择应该更安全。

于 2013-06-04T11:17:06.547 回答
0

使用重定向器操作助手

$this->_helper->redirector('auth','login');
于 2013-05-30T18:44:34.177 回答