Custom 404 Not Found Error Pages in CakePHP 2.0+

You may also like...

  • Pingback: CakePHP: 定制个性化的错误信息 « 静水深流 || Still waters run deep()

  • Very helpful thanks !!
    Cake can be a pain in the @ss sometimes… good to find well written tutorials 🙂

  • Great tutorials, thank you!

    It’s really helpful.

  • Giuppe

    This is great!
    However, usring $this->redirect() resets my status code to 302, why?

    • Jordan Hopfner

      Ahh yes you are right, sorry I totally missed that. I’ve updated the redirect code to include a status code, please see the section “Redirect to another page?”. You’ll notice a 404 code is now passed to the redirect function rather than sending a header that gets overwritten.

  • This is great; thanks.  What about themes though? Using this method and setting the layout to default uses the app/default not the theme default.ctp

    any ideas?


    • Jordan Hopfner

      Sorry I’m a little late to the party on this comment Will, I haven’t tried it but I would assume all you need to do is set the theme through the controller object. For example, $this->controller->theme = 'ThemeName';.

  • Hello Thanks for tutorial, I use 2.3 version
    But if I changed core.php in Configure::write(‘debug’, 2); with Configure::write(‘debug’, 0);
    It’s not working 🙁

    • Jordan Hopfner

      I haven’t got a chance to test this on 2.3, what problem are you having when you say it’s not working?