For CakePHP errors I know that there exists CakeError and AppError solutions. But I need to make a redirection within controller.
In AppController there exists:
function afterFilter() {
if ($this->response->statusCode() == '404')
{
$this->redirect(array(
'controller' => 'mycontroller',
'action' => 'error', 404),404
);
}
}
But this doesn't create a 404 status code. It creates a 302 code. I changed code to this:
$this->redirect('/mycontroller/error/404', 404);
But the result is same.
I added this, it didn't work also deprecated:
$this->header('http/1.0 404 not found');
How can I send a 404 code within controller redirect ?