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...
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