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

[eluser]Henrik Pejer[/eluser]
So this is what I've come up with (so far?):
Code:
class MY_Exceptions extends CI_Exceptions{
    
    function MY_Exceptions(){
        parent::CI_Exceptions();
    }
    
    function show_404($page=''){
        # Your code here...
        
        # end with redirect to the custom 404 handler
        # add on the end the request-uri (might only work with apache)
        header('Location: /custom404controller'.$_SERVER['REQUEST_URI']);
        exit;
    }
}

Instead of extending routes, I extend exceptions, like coolfactor and others suggest. To be able to use a custom 404 controller, though, I have to redirect.

There, now we have the possibility to have a controller that can handle 404-errors and also use the complete CI framework. I really should have thought this through one more time before posting my initial code, sorry for that!

Happy CI:ing!


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