Jump to content

How to make 404 page for Kohana Framework


Recommended Posts

Im a Kohana newbie. How and where do you make a custom 404 page for Kohana framework.  I have read a few posts that give code but I am unable to get that going.  Apparently you create a errors.php file in application\hooks\errors.php but its not working.

 

Where in Kohana do you set a global path to a view for any 404 errors?

I have Googled it, as well as searched on the Kohana forums.  All the code examples assume you know how the framework works inside-out. I am using version 2.3.4.  All I need to know is just the path to the file where I can set a default controller/view for any 404 errors, if such a method exists in Kohana.

I've figured out a way to redirect any 404 errors to a single controller.  It's probably not the best way, but it works like a charm.

 

Find system\libraries\Router.php

If your file is still untouched, the code you want to add will be on line 162

 

Simply redirect to your 404 error controller.

 

if (Router::$controller === NULL)
        {
            // No controller was found, so no page can be rendered
            url::redirect(url::site()."notfound");
            exit;
           // Event::run('system.404');
        }

 

I'm sure you can figure out the rest from here...

I'd switch off Kohana if I was you.  I used to use it for years, however their documentation tends to be incomplete, they break old cold with new updates, and they don't offer downloadable documentation.  It's also hard to find help with it because it's really not that popular.  I switched to codeigniter and I've been happier with it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.