Search code examples
phpcodeigniter-2

codeigniter routing not working for single view page also


I have single controller and one view page when i try to load this view page using controller I am getting 404 error even route has set.

Controller:

class Navigation extends CI_Controller{

    public function index(){
        $this->load->view('header');

    }

}

In the view directory i had place a file with the name of header and it contains as "Test Navigation" in body that's it.

Routing file:

$route['default_controller'] = "welcome";
$route['404_override'] = '';
$route['menu'] = 'Navigation';

This CI script placed under directory of books. So when i type as localhost/books/index.php/menu , I am getting 404 error. Please explain how to solve this.


Solution

  • Controller class name & controller filename should be same. class Navigation should be under Navigation.php.

    Note: This rules applied for the Model too.