Karthi prime Karthi prime - 1 year ago 80
PHP Question

Codeignitor 404 error

I am following the tutorial-Static pages, from codeignitor website.

  1. I extracted the codeignitor zip into my local server.

  2. Edited the line


in application /config/config.php

  1. Created the file: application/controllers/pages.php to have following contents:


    class Pages extends CI_Controller {

    public function view($page = 'home')
    if ( ! file_exists('/var/www/application/views/pages/'.$page.'.php'))
    // Whoops, we don't have a page for that!

    $data['title'] = ucfirst($page); // Capitalize the first letter

    $this->load->view('templates/header', $data);
    $this->load->view('pages/'.$page, $data);
    $this->load->view('templates/footer', $data);

  2. Created the file: application/views/templates/header.php with some HTML content.

  3. Created the file: application/views/templates/footer.php with some HTML content.

Now, when I go to


I expect the 'about' page, but 404 error is shown.

Why is that?

Answer Source

please try following

if (file_exists(APPPATH."views/pages/". $page. ".php")) {

   $this->load->view("pages/". $page);


APPPATH = well self explanatory