How to create static pages in codeIgniter

Create pages.php in controller/ folder.

Add the following codes.

class Pages extends CI_Controller {
public function view($page = 'home')

if ( ! file_exists('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);


Create header.php and footer.php inside application/view/templates/ folder.

Create about.php inside the folder application/view/pages/

Edit /application/config/routes.php

$route['about'] = 'pages/view/about';

Now we will be able to view the page at http://domainname/index.php/about

Leave a Reply