views:

17

answers:

2

This should be simpler. What do I need to define what should happen in place of a 404 error?

A: 

Read a little bit more on Error Handling for CodeIgniter. If that doesn't completely satisfy you, try editing your 404.php error file to make it do whatever you want it to do.

Raphael Caixeta
Nope, it's not allowing some stuff in the 404.php file, and that Error Handling document is sparse. I want to write a pre-controller hook to handle the errors.
Josh K
+1  A: 

Check out my answer for CI Base URI Routing.

What you can do is extend CI's Router to re-route requests for non-existent controllers to your own error handling controller.

However, with CodeIgniter 2.0 (which I have been using with no problems at all in the real world), this is as easy as setting a 404_override config item that routes all invalid controller requests to your own controller in the exact same way without having to extend CI with your own library.

Either way, you could write your own error handling methods using the exact same functionality you would be able to use in any other controller.

bschaeffer
I will check out 2.0, thanks!
Josh K
Cool... make sure you check out this article (http://philsturgeon.co.uk/news/2010/05/upgrading-to-codeigniter-2.0) on upgrading to CI 2.0 by SO user Phil Sturgeon (http://stackoverflow.com/users/124378/phil-sturgeon). Points out the steps you need to take for upgrading (and checkout the change log in the 2.0 user guide for new features like Drivers and package paths).
bschaeffer