Custom view in show_404() not working Custom view in show_404() not working codeigniter codeigniter

Custom view in show_404() not working


I got the solution from this link - CodeIgniter 2.1 issue with show_404() and 404_override.

<?php// application/core/MY_Exceptions.phpclass MY_Exceptions extends CI_Exceptions {    public function show_404()    {        $CI =& get_instance();        $CI->load->view('my_notfound_view');        echo $CI->output->get_output();        exit;    }}

Thanks a lot for all the help. Appreciated :)


If you want to show custom 404 template

You need to change $route['404_override'] = 'welcome/page_not_found'; in config/routes.php file.

and write the action in controller

public function page_not_found(){    $this->data['page_title'] = 'Page Not Found!';    $this->load->view('layouts/page_not_found.php', $this->data);}

Important:Your page_not_found action should be in your default controller(You can set default controller from config/routes.php, $route['default_controller'] = 'welcome';)


Try to changing the config.php to

$config['uri_protocol'] = "REQUEST_URI";

it work ?.