title: CodeIgniter: The page you requested was not found
body: <p>I have the following error:</p>
  
  <blockquote>
    <p>404 Page Not Found</p>
    
    <p>The page you requested was not found.</p>
  </blockquote>
  
  <p>Posted below are my code files.</p>
  
  <p>Controller code:</p>
  
  <pre><code>&lt;?php
    defined('BASEPATH') OR exit('No direct script access allowed');
    /**
     *
     */
    class Pages extends CI_Controller
    {
  
      public function view($page='home')
      {
        # code...
        if (!file_exists(APPPATH.'views/ds_pages/'.$page.'.php')) {
          # code...
          show_404();
        }
        $data['title']=ucfirst($page);
        $data['portfolios']= $this-&gt;page_model-&gt;get_portfolios(FALSE);
              $this-&gt;load-&gt;view('templates/header');
              $this-&gt;load-&gt;view('ds_pages/'.$page,$data);
              $this-&gt;load-&gt;view('templates/footer');
      }
  
      public function portfolio_view($slug= NULL)
      {
        # code...
        $data['portfolio']=$this-&gt;page_model-&gt;get_portfolios($slug);
  
        if (empty($data['portfolio'])) {
          # code...
          show_404();
        }
  
        $data['title']= $data['portfolio']['title'];
              $this-&gt;load-&gt;view('templates/header');
              $this-&gt;load-&gt;view('ds_pages/portfolio_view',$data);
              $this-&gt;load-&gt;view('templates/footer');
      }
  
      public function create(){
              # code...
              $data['title']= 'Create Portfolio';
  
              $this-&gt;form_validation-&gt;set_rules('title','Title','required');
              $this-&gt;form_validation-&gt;set_rules('body','Body','required');
              if($this-&gt;form_validation-&gt;run() === FALSE){
                  $this-&gt;load-&gt;view('templates/header');
                  $this-&gt;load-&gt;view('ds_pages/create',$data);
                  $this-&gt;load-&gt;view('templates/footer');
              }else{
                  $config['upload_path']= './assets/images/pages';
                  $config['allowed_types']= 'gif|jpg|png';
                  $config['max_size']= '2048';
                  $config['max_width']= '2000';
                  $config['max_height']= '2000';
  
                  $this-&gt;load-&gt;library('upload',$config);
                  if (!$this-&gt;upload-&gt;do_upload()) {
                      # code...
                      $errors=array('error'=&gt; $this-&gt;upload-&gt;display_errors());
                      $portfolio_image='placeholder.png';
                  }else{
                      $data=array('upload_data' =&gt; $this-&gt;upload-&gt;data());
                      $portfolio_image= $_FILES['userfile']['name'];
                  }
  
                  $this-&gt;page_model-&gt;create_portfolio($portfolio_image);
                  //set message
                  $this-&gt;session-&gt;set_flashdata('portfolio_created','Your portfolio has been created');
  
                  redirect('pages/view');
              }
          }
    }
  
  
   ?&gt;
  </code></pre>
  
  <p>Then in Model I have the following code:</p>
  
  <pre><code>&lt;?php
    /**
     *
     */
    class Page_model extends CI_Model
    {
  
      public function __construct()
      {
        # code...
        $this-&gt;load-&gt;database();
      }
  
      public function get_portfolios($slug=FALSE){
                  # code...
            if ($slug === FALSE) {
              # code...
              $query= $this-&gt;db-&gt;get('portfolios');
              return $query-&gt;result_array();
            }
            $query= $this-&gt;db-&gt;get_where('portfolios', array('slug' =&gt; $slug));
                    return $query-&gt;row_array();
              }
        public function create_portfolio($portfolio_image)
          {
              # code...
              $slug= url_title($this-&gt;input-&gt;post('title'));
              $data= array(
                      'title' =&gt; $this-&gt;input-&gt;post('title'),
                      'slug'=&gt;$slug,
                      'body'=&gt;$this-&gt;input-&gt;post('body'),
                      'portfolio_image'=&gt; $portfolio_image
                  );
              return $this-&gt;db-&gt;insert('portfolios',$data);
          }
    }
  
   ?&gt;
  </code></pre>
  
  <p>And this is my View:</p>
  
  <pre><code>&lt;small class="post-date"&gt;&lt;?php echo $portfolio['created_at']; ?&gt;&lt;/small&gt;&lt;br/&gt;
  &lt;div class="row"&gt;
      &lt;div class="col-md-3"&gt;
          &lt;img src="&lt;?php echo site_url();?&gt;assets/images/pages/&lt;?php echo $portfolio['portfolio_image'];?&gt;"&gt;
      &lt;/div&gt;
      &lt;div class="col-md-9"&gt;
          &lt;h2&gt;&lt;?php echo $portfolio['title']; ?&gt;&lt;/h2&gt;
          &lt;div class="post-body"&gt;
              &lt;?php echo $portfolio['body']; ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;hr/&gt;
  &lt;a class="btn btn-info pull-right" href="edit/&lt;?php echo $portfolio['slug']; ?&gt;"&gt;Edit&lt;/a&gt;
  &lt;?php echo form_open('/pages/delete/'.$portfolio['id']);?&gt;
    &lt;input type="submit" name="delete" class="btn btn-danger" value="Delete" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Finally, this code bellow is routes.php:</p>
  
  <pre><code>&lt;?php
  defined('BASEPATH') OR exit('No direct script access allowed');
  
  
  $route['pages/view']='pages/view';
  $route['pages/create']='pages/create';
  $route['pages/(:any)']='pages/portfolio_view/$1';
  $route['pages']='pages/view';
  
  $route['default_controller'] = 'pages/view';
  $route['404_override'] = '';
  $route['translate_uri_dashes'] = FALSE;
  </code></pre>
  
  <p>Please Help me and thank you in advance.</p>