Welcome Guest, Not a member yet? Register   Sign In
Custom 404 controller like any other controller
#5

[eluser]Henrik Pejer[/eluser]
@sophistry:

The problem is that the server never gets the 404-error since all requests are routed through the index.php-file of CI. Its CI that send the 404-error, nothing else.

Something struck me: you could modify the show_404() function to redirect you to a custom error-page instead of extending the Routes_class. This way you can have a controller that will handle all you 404-errors

@Coolfactor:

I agree, its a much cleaner way of doing things, but the only problem I have with show_404 is that the complete CI-system has not loaded, so you can't directly in that function put calls to the db etc. Or you can, but it wouldn't be using CI-classes or you'd have to mimic the startup behaviour of CI in that function.

I think that modifying the show_404 to redirect to /custom404controller/ is much better, then what I did above. Its only a shame that I figured this out just now, instead of before I posted that code...

Thanks for you answers, sophistry and coolfactor!


Messages In This Thread
Custom 404 controller like any other controller - by El Forum - 06-23-2007, 08:35 AM
Custom 404 controller like any other controller - by El Forum - 06-24-2007, 08:49 PM
Custom 404 controller like any other controller - by El Forum - 06-24-2007, 08:51 PM
Custom 404 controller like any other controller - by El Forum - 06-24-2007, 09:12 PM
Custom 404 controller like any other controller - by El Forum - 06-25-2007, 12:51 AM
Custom 404 controller like any other controller - by El Forum - 06-25-2007, 01:26 AM
Custom 404 controller like any other controller - by El Forum - 07-13-2007, 08:05 AM
Custom 404 controller like any other controller - by El Forum - 07-13-2007, 09:09 PM
Custom 404 controller like any other controller - by El Forum - 11-16-2007, 09:23 AM
Custom 404 controller like any other controller - by El Forum - 11-16-2007, 10:06 AM
Custom 404 controller like any other controller - by El Forum - 11-16-2007, 11:23 AM
Custom 404 controller like any other controller - by El Forum - 11-16-2007, 12:47 PM
Custom 404 controller like any other controller - by El Forum - 11-16-2007, 01:09 PM
Custom 404 controller like any other controller - by El Forum - 08-08-2008, 08:53 AM
Custom 404 controller like any other controller - by El Forum - 10-07-2008, 07:45 AM
Custom 404 controller like any other controller - by El Forum - 10-07-2008, 07:52 AM
Custom 404 controller like any other controller - by El Forum - 10-07-2008, 07:53 AM
Custom 404 controller like any other controller - by El Forum - 03-13-2010, 10:37 AM
Custom 404 controller like any other controller - by El Forum - 11-09-2010, 07:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB