Monday, July 14, 2014

Re: Sending a 404 header from the controller

On Fri, Jul 11, 2014 at 2:31 PM, Alex Bovey <alex@bovey.co.uk> wrote:
>
> Hello all,
>
> I would like one of my controller methods to be able to send a 404 Not Found header, but still render the view as normal. I've tried both of the following at the beginning of my controller method, but Cake is still returning a 200 OK header:
>
> $this->response->header('HTTP/1.1 404 Not Found');
> $this->response->httpCodes(404);

Solved. For anyone that finds this in future the function is
$this->response->statusCode(404) not $this->response-> httpCodes(404).

Alex

--
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England & Wales no. 6471391 | VAT no. 934 8959 65
alex@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
PHP | CakePHP | MySQL | jQuery | HTML5 | CSS3 | Drupal | Wordpress | Hosting

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: