I am following the tutorial-Static pages, from codeigniter website.
Edited the line
$config['base_url']='http://localhost/';
in application /config/config.php
Created the file: application/controllers/pages.php to have following contents:
<?php
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!
show_404();
}
$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);
}
}
Created the file: application/views/templates/header.php with some HTML content.
Created the file: application/views/templates/footer.php with some HTML content.
Now, when I go to
localhost/index.php/pages/view/about
I expect the 'about' page, but 404 error is shown.
Why is that?
please try following
if (file_exists(APPPATH."views/pages/". $page. ".php")) {
$this->load->view("pages/". $page);
}
APPPATH
= well self explanatory