title: Codeigniter Pagination links not working. Showing 404 page.
body: <p>This is my first time doing pagination. Everything working fine except the the 1 2 3.... link part on my view. The result from database also showing perfectly. But whenever I click on the 2 it leads to a 404 page. </p>
  
  <p>My view link: <a href="http://localhost/learn/site/index/" rel="nofollow">http://localhost/learn/site/index/</a>
  When I click on the 2 : <a href="http://localhost/learn/site/index/10" rel="nofollow">http://localhost/learn/site/index/10</a></p>
  
  <p>My controller: </p>
  
  <pre><code>public function index(){
          $this-&gt;load-&gt;model('model_users');
          //--------------------Pagination----------------------
          $this-&gt;load-&gt;library('pagination');
          $config['base_url'] = base_url().'site/index'; ;
          $config['total_rows'] = $this-&gt;db-&gt;get('posts')-&gt;num_rows();
          $config['uri_segment'] = 3;
          $config['per_page'] = 10; 
          $this-&gt;pagination-&gt;initialize($config); 
  
          $pag = $this-&gt;db-&gt;order_by("post_id", "desc")-&gt;get('posts', $config['per_page'], $this-&gt;uri-&gt;segment(3));        
          $table_data_home['allposts'] = $pag-&gt;result();
  
          //------------end pagination-------------------------
  
  
          $this-&gt;load-&gt;view('my_site',$table_data_home);
  
  }`
  </code></pre>
  
  <p>Here is my view: </p>
  
  <pre><code>         &lt;?php
  foreach($allposts as $posts){
      $title = $posts-&gt;post_title;
      $name = $posts-&gt;name;
      $categories = $posts-&gt;category;
      $post = $posts-&gt;post;
      $pic = $posts-&gt;pic;
      $time = $posts-&gt;time;
      $post_id = $posts-&gt;post_id;
          ?&gt;
            &lt;div id="allsinglepost"&gt; &lt;a href="&lt;?php echo site_url('site/full_post'); ?&gt;?post_id=&lt;?php echo $post_id ?&gt;"&gt;
              &lt;h3&gt;&lt;?php echo $title;?&gt;&lt;/h3&gt;
              &lt;/a&gt;
              &lt;hr class="post_inside_hr"&gt;
              &lt;h6&gt;&lt;b&gt;Written By :&lt;/b&gt; &lt;?php echo $name ;?&gt;&lt;/h6&gt;
              &lt;h6&gt;&lt;b&gt;Date:&lt;/b&gt;
                &lt;?php  echo substr($time,0,10).'; Time: '.substr($time,11,12); ?&gt;
              &lt;/h6&gt;
              &lt;hr class="post_inside_hr"&gt;
              &lt;div id="post_description"&gt;
                &lt;p&gt;&lt;?php echo substr($post,0,200) ;?&gt; ........&lt;/p&gt;
              &lt;/div&gt;
            &lt;/div&gt;
            &lt;hr id="postbreakline"&gt;
            &lt;?php } ?&gt;
            &lt;!--The upper part will be a FOREACH for posts--&gt; 
  
            &lt;!-- pagination part --&gt;
            &lt;?php
            echo $this-&gt;pagination-&gt;create_links();
  
            ?&gt;
  </code></pre>
  
  <p>Can anyone tell me where is the problem? I am stuck here. </p>