CodeIgniter – custom 404 error page

application/config/routes.php

$route['404_override'] = 'my404';

application/controllers/My404.php

<?php 
class My404 extends CI_Controller 
{
    public function __construct() 
    {
        parent::__construct(); 
    } 

    public function index() 
    { 
        $this->output->set_status_header('404'); 
        $data['content'] = 'error_404'; // View name 
        $this->load->view('index', $data);//loading in my template 
    } 
}

Leave a Reply

Your email address will not be published. Required fields are marked *