How to create custom 404 page in codeigniter

How to create custom 404 page in codeigniter

You can create your custom 404 page with these steps. Please follow these steps one by one.
  • Step 1
  • create your new controller "Controller_Class_Name" file in your controllers directory application/controllers/.
    Please put this code in your Controller_Class_Name.php
    class Controller_Class_Name extends CI_Controller {
         public function __construct() {
              parent::__construct();
         }
    
        public function index() {
             $this->output->set_status_header('404');
             $this->load->view('error_page_404');
        }
    }
    
  • Step 2
  • Now You have to update this in your application/config/routes.php
     $route['404_override'] = 'Controller_Class_Name';. 

  • Step 3
  • Now create your "error_page_404" view file. in your view directory application/views/

We are Recommending you:

Leave a comment

Comments