Broken links will give a bad impression to your users. So always do an analysis on your website using some tools if there is any broken link in the navigation links. But you can not fix the broken links from external websites to your website. Also some user might type a url to your website with spelling mistake. So it is always nice to have a good Page-not-found page to keep a good impression. You can implement a Page-not-found page in easy 3 steps given below.
- First open routes.php in application/config and set a custom controller name.
$route['404_override'] = 'my404'; //Here my404 is my controller class name.
- Create a new controller and write the following code in it. The code is very easy to understand. So I am not going to explain it here.
<?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 } } ?> - Create a view file with name ‘error_404.php’ with your custom message.
That is all.

very interesting, thanks
Sorry, it works, but only for non-controllers. If you want to enter to something like that:
http://www.url.com/existing-controller/non-method
it doesn’t work
After making the hlloowerld.php and index_view.php files when i test it in the brower it gives the following error : Fatal error: Class Controller’ not found in C:\xampp\htdocs\CodeIgniter\application\controllers\helloworld.php on line 2 Since i am new to codeigniter plz help me with this issue.
instresting
Do you have a controller with the default controller name? Try removing the underscore in the controller name.
working fine