title: CodeIgniter pagination not working when clicking on a link
body: <p>probably this problem is really stupid but I tried lot of things and I always get the same error ...</p>
  
  <p>As you can see, I'm trying to use Pagination in CodeIgniter and I can load a view with the pages and links but when I click on a link it says <strong>"Object not found!"</strong> </p>
  
  <p>This is my Controller:</p>
  
  <pre><code>class Controller extends CI_Controller {
  
      public function __construct() {
          parent:: __construct();
          $this-&gt;load-&gt;helper("url");
          $this-&gt;load-&gt;model("Blogs_model");
          $this-&gt;load-&gt;library("pagination");
      }
  
      public function index() {
          $config = array();
          $config["base_url"] = base_url() . "pagination/";
          $config["total_rows"] = $this-&gt;Blogs_model-&gt;record_count();
          $config["per_page"] = 2;
          $config["uri_segment"] = 3;
          $config['first_link'] = 'First';
          $config['last_link'] = 'End';
          $config['next_link'] = 'Next &amp;rarr;';
          $config['prev_link'] = '&amp;larr; Prev';
  
          $this-&gt;pagination-&gt;initialize($config);
  
          $page = ($this-&gt;uri-&gt;segment(3)) ? $this-&gt;uri-&gt;segment(3) : 0;
          $data["results"] = $this-&gt;Blogs_model-&gt;fetch_entries($config["per_page"], $page);
          $data["links"] = $this-&gt;pagination-&gt;create_links();
  
          $this-&gt;load-&gt;view("example1", $data);
      }
  }
  </code></pre>
  
  <p>routes.php:</p>
  
  <pre><code>route['default_controller'] = "controller";
  $route['pagination/(:any)'] = 'pagination';
  $route['404_override'] = '';
  </code></pre>
  
  <p>config.php:</p>
  
  <pre><code>config['base_url']  = 'http://localhost/ci';
  </code></pre>
  
  <p>Could someone help me please? Thank you.</p>
  
  <p><strong>EDIT</strong>
  Thats my model:</p>
  
  <pre><code>class Blogs_model extends CI_Model {
  
      public function __construct() {
          parent::__construct();
      }
  
      public function record_count() {
          return $this-&gt;db-&gt;count_all("entry");
      }
  
      public function fetch_entries($limit, $start) {
          $this-&gt;db-&gt;limit($limit, $start);
          $query = $this-&gt;db-&gt;get("entry");
  
          if ($query-&gt;num_rows() &gt; 0) {
              foreach ($query-&gt;result() as $row) {
                  $data[] = $row;
              }
              return $data;
          }
          return false;
      }
  }
  </code></pre>
  
  <p>And the problem is that when I load the page: localhost/ci/ it works correctly, but when I click on a link the url changes to localhost/ci/pagination/2 and doesn't work. I guess its a problem of routes but anyway I'm not sure.</p>
  
  <p><strong>EDIT 2</strong>
  Thanks for all the comments guys, finally I manage to get it working but with the Index.php active, I mean my url now is: </p>
  
  <pre><code>http://localhost/ci/index.php/controller/index/2 
  </code></pre>
  
  <p>and I would like to get it working without the index.php. My code right now is this:
  Controller:</p>
  
  <pre><code>class Controller extends CI_Controller {
  
      public function __construct() {
          parent:: __construct();
          $this-&gt;load-&gt;helper("url");
          $this-&gt;load-&gt;model("Blogs_model");
          $this-&gt;load-&gt;library("pagination");
      }
  
      public function index() {
          $config = array();
          $config["base_url"] = "http://localhost/ci/index.php/controller/index";
          $config["total_rows"] = $this-&gt;Blogs_model-&gt;record_count();
          $config["per_page"] = 2;
  
          $this-&gt;pagination-&gt;initialize($config);
  
          $data["results"] = $this-&gt;Blogs_model-&gt;fetch_entries($config["per_page"], $this-&gt;uri-&gt;segment(3));
          $data["links"] = $this-&gt;pagination-&gt;create_links();
  
          $this-&gt;load-&gt;view("example1", $data);
      }
  }
  </code></pre>
  
  <p>And the base_url from the config.php is </p>
  
  <pre><code>http://localhost/ci;
  </code></pre>
  
  <p>Also the routes file now only has:</p>
  
  <pre><code>$route['default_controller'] = "controller";
  $route['404_override'] = '';
  </code></pre>