phphttp-status-code-404kohanakohana-2

Kohana 2 Custom 404 error pages


In Kohana 2 you can override the default error page by creating a custom kohana_error_page.php file and putting it in your view directory. However, this overrides ALL errors not just 404's. In the case of 500 errors, I'd still like to get the friendly orange kohana error page.

Does anyone have experience in doing this?


Solution

  • I have not tested this!! So backup your code before you do this.

    If I'm not mistaken, Kohana2 has hard-coded exception handling and there is no pretty way to add new exceptions. To work around that, you will have to make change in the core.

    In the file system/i18n/en_US/errors.php

    In the file system/i18n/en_US/core.php

    In the system/core/Koahana.php:

    Now you should be able to call Event::run('system.403'); from anywhere in the application.