
Create controller application\controllers\My404.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?php defined( 'BASEPATH' ) OR exit ( 'No direct script access allowed' ); class My404 extends CI_Controller { public function __construct() { parent::__construct(); } public function index() { $this -<output-<set_status_header( '404' ); $this -<load-<view( 'err404' ); } } |
Create View application\views\err404.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <!DOCTYPE html> <html lang= "en" > <head> <meta charset= "utf-8" > <title>404 Page</title> </head> <body> <div> <p>How to Create Custom Codeigniter 404 Error Pages </p> <p align= "center" style= "font-size:55px;" >Sorry Page Not Found</p> <p align= "center" style= "font-size:55px;" >Error 404</p> <div> <p align= "center" ><a href= "<?php echo base_url(); ?>" >Go Back to Home</a></p> </div> </div> </body> </html> |
add 404 to application\config\route.php $route['404_override'] = 'my404';