title: Getting 404 errors for codeigniter pagination
body: <p>this is my class:</p>
  
  <pre><code>class Pacients extends CI_Controller {
      public function __construct(){
          parent::__construct();
          $this-&gt;load-&gt;helper(array('form', 'url'));
          $this-&gt;load-&gt;library('form_validation');
          $this-&gt;load-&gt;library('email');
          $this-&gt;load-&gt;library('session');
          $this-&gt;load-&gt;library('pagination');
  
          $this-&gt;load-&gt;model('pacient_model');
          $this-&gt;load-&gt;model('department_model');
      }
      public function index(){
          $id_doctor = $this-&gt;session-&gt;userdata('userid');
          $department = $this-&gt;department_model-&gt;get_department_by_doctor($id_doctor); // get deparmentd_id
          $diagnostics = $this-&gt;department_model-&gt;get_diagnostics($department[0]-&gt;department_id); // get diagnostics by using deparment id 
          $department_data = $this-&gt;department_model-&gt;get_department_by_id($department[0]-&gt;department_id); // get all info about deparment
  
          //start pagination 
          if ($this-&gt;uri-&gt;segment(2) == null || $this-&gt;uri-&gt;segment(2) == ""){
              $limit = 0;
          }else{
              $limit = $this-&gt;uri-&gt;segment(2);
          }
          $get_pacients = $this-&gt;pacient_model-&gt;get_pacients_by_doctor($id_doctor, $limit);
          $total = $this-&gt;pacient_model-&gt;get_total_pacients_by_doctor($id_doctor);
          $config['base_url']   = base_url().'pacients';
          $config['total_rows'] = $total[0]-&gt;total;
          $config['per_page']   = 3;
          $this-&gt;pagination-&gt;initialize($config);
          // end pagination
          $data = array(
              'pacients'        =&gt; $get_pacients,
              'diagnostics'     =&gt; $diagnostics,
              'department_data' =&gt; $department_data
          ); 
          if (!$diagnostics){// check if there any diagnostic in db associated to the current department
              $data['error'] = 1;// if it is 1 then a form will apears in the view
          }
  
          $this-&gt;load-&gt;view('frontend/common/header');
          $this-&gt;load-&gt;view('frontend/pacients',$data);
          $this-&gt;load-&gt;view('frontend/common/footer');
      } 
  }
  </code></pre>
  
  <p>In the get_pacients variable I have all of the results and I got all of the wanted results. in view in shows me the pagination. but when i clicked on the page 2 it shows me the 404 page.  It is weird, on another page i used the same pagination implementation and it works. The url looks like:</p>
  
  <pre><code>http://localhost/licenta/pacients  
  </code></pre>
  
  <p>Do you have any idea why I get the 404 ? I am using Codeigniter 3. Thx in advance</p>