CodeIgniter Tutorial on Static Pages

I started using the first sample tutorial at http://ellislab.com/codeigniter%20/user-guide/tutorial/static_pages.html .

I always get a problem with the page not found! I have read many articles to solve the problem. But no matter how often I try solutions in different forums, it does not work!

Can someone please tell me where my errors are?

So these are some files I tried:

My .php routes in / config application

$route['default_controller'] = "pages/view";
$route['404_override'] = '';
$route['(:any)'] = 'pages/view/$1';

My .php pages in application / controllers

<?php
   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!
        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);
    }
}

My home.php and about.php are in the app / views / pages / and header.php and footer.php are in the app / views / templates /

Many thanks!

+4
5

, , , , , , URL- . obviosuly false, .

0

/config/routes.php

$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';

$route['default_controller'] = 'pages/views';
$route['404_override'] = '';

, . , .

0

/application/config/routes.php :

$route['default_controller'] = "pages/view";
$route['(:any)'] = 'pages/view/$1';
$route['404_override'] = '';

CodeIgniter , 404 .

0

Be sure to carefully follow the directions. I had the same problem and finding a solution. Only after reading some of these answers did I realize that I did not create subdirectories templatesor pagesin a directory views. When you get to the end of the static pages tutorial , you should have the following structure:

/views/
   /templates/
     header.php
     footer.php
   /pages/
     about.php
     home.php
0
source

First run this

$route['default_controller'] = 'welcome';
$route['404_override'] = '';

Then try this

$route['default_controller'] = "pages/view";
$route['404_override'] = '';

I had the same problem, but it was not resolved.

0
source

All Articles