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

[eluser]sophistry[/eluser]
that's cool! thanks for sharing that code.

what would happen if you put an errordocument directive in your .htaccess file? would that solve this problem too? i have not tried it, but putting a single directive in the webserver config file is more appealling to me than extending the router class... just curious if you use apache and/or have tried something like this:

Code:
ErrorDocument 404 /page_not_found

and then make a page_not_found controller. would that directive run properly if put after the mod_rewrite stuff too? can the errordocument handle parameters in the parameters? hmnnn... just talking off the tips of my fingers...

also, before you go extending the core files you should note that the exceptions class show404() function logs the 404 error before displaying the page:
Code:
/**
     * 404 Page Not Found Handler
     *
     * @access    private
     * @param    string
     * @return    string
     */
    function show_404($page = '')
    {
        $heading = "404 Page Not Found";
        $message = "The page you requested was not found.";

        log_message('error', '404 Page Not Found --> '.$page);
        echo $this->show_error($heading, $message, 'error_404');
        exit;
    }

so, you could add this line to the custom404() function:
Code:
log_message('error', '404 Page Not Found --> '.$segment_string);

finally, you might want to pass the $segments argument to the custom404() method so that it can use the mistyped/erroneous controller name to help the user.

best... and let us know if you decide to try out the apache errordocument directive.


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