codeigniter 3.0 custom 404 not found error page

后端 未结 4 705
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-05 11:53

My problem is about custom error pages after upgrading to Codeigniter 3.0.

I used to have a Errors controller which handled 404 error page of the websi

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-05 12:22

    that is working good, but if redirect to an error, for example 404 with function show_404, your controller wont load your view, for a real 404 in the show_404 method, you have to go to the core of codeigniter and touch it.

    \system\core\Common.php

    this is an example of code:

    function show_404(){
      $ci = get_instance();
      $ci->output->set_status_header(404);
      $ci->load->view('errors/error404_view');
      echo $ci->output->get_output();
      exit(4);
    }
    

提交回复
热议问题