【发布时间】:2012-07-01 09:38:58
【问题描述】:
对于 CakePHP 错误,我知道存在 CakeError 和 AppError 解决方案。 但我需要在控制器内进行重定向。
在AppController中存在:
function afterFilter() {
if ($this->response->statusCode() == '404')
{
$this->redirect(array(
'controller' => 'mycontroller',
'action' => 'error', 404),404
);
}
}
但这不会创建 404 状态代码。它创建一个 302 代码。 我将代码更改为:
$this->redirect('/mycontroller/error/404', 404);
但结果是一样的。
我添加了这个,它也被弃用了:
$this->header('http/1.0 404 not found');
如何在控制器重定向中发送 404 代码?
【问题讨论】:
标签: php cakephp redirect http-status-code-404 cakephp-2.0