(06-20-2017, 02:12 AM)wolfgang1983 Wrote: (06-20-2017, 02:05 AM)reactionstudio Wrote: If you create the file: application/core/MY_Exceptions.php with the following code what happens?
PHP Code:
<?php
class MY_Exceptions extends CI_Exceptions {
function __construct() {
parent::__construct();
}
public function show_404($page = '', $log_error = TRUE)
{
if (is_cli())
{
$heading = 'Not Found';
$message = 'The controller/method pair you requested was not found.';
}
else
{
$heading = '404 Page Not Found';
$message = 'The page you requested was not found.';
}
if ($log_error)
{
log_message('error', $heading.': '.$page);
}
if( is_cli() ) {
echo $this->show_error($heading, $message, 'error_404', 404);
} else {
header("HTTP/1.0 404 Not Found");
header('location: http://www.yoursite.com/notfound');
}
exit(4); // EXIT_UNKNOWN_FILE
}
}
dont forget to replace www.yoursite.com with your applications domain. If it works you'll need to change how the base_url is passed in but this should be enough to see if it makes progress towards a solution.
Thanks that works also.
This will work, but you are both missing the fact that the 404_override and show_404 are not directly related. Setting the one does not change the workings of the other. IMHO changing the show_404 to fix something that is not broken because of a lack of knowledge is not the way to do things.
Instead create a show_notfound() method that will handle the redirect to your custom Controller. This way you can keep using the show_404 as is, also within your custom Controller without causing an infinite redirect loop.