Wednesday, April 19, 2017

How to Create a Custom 404 Page in codeigniter

To Create a Custom 404 Page in CodeIgniter. I will tell you the  quick and easiest way.

1. Find Create a View Page as per your design requirements
2. Next define a route in config/routes.php like this

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

3. Next Create a New Controller in your application/controller with the name MyCustom404Page

4. Then paste the below code in the newly created controller

<?php

class MyCustom404Page extends CI_Controller  {
    public function __construct() {
        parent::__construct();
    }

    public function index(){
        $this->output->set_status_header('404');

        // Make sure you actually have some view file named 404Page.php
        $this->load->view('404Page'); // Your View Page Name
    }
}

?>

Thats it now the custom 404 page is ready...

No comments:

Post a Comment

How to get Logged In Username in Wordpress or Woocommerce

It is really easy to get the logged-in user’s information in Wordpress or Woocommerce. In this article we will show you how to get the relat...