title: CodeIgniter - routing and pagination
body: <p>This is my first attempt at pagination in CI, and I am facing a little problem, propably caused by routing.</p>
  
  <p>My rules are as follow:</p>
  
  <pre><code>$route['User/(:num)/(:any)'] = 'User/index/$1';
  $route['user/(:num)/(:any)'] = 'User/index/$1';
  </code></pre>
  
  <p>Those are translated to something like <code>http://site.com/index.php/user/1/tomek</code>. </p>
  
  <p>Now my pagination controller:</p>
  
  <pre><code>$config['base_url'] = site_url('user').'/'.$user.'/'.$data['user'][0]['nick'].'/';
  $config['total_rows'] = $this-&gt;rating_model-&gt;countOwned($user);
  $config['per_page'] = 2;
  $config['enable_query_strings'] = true;
  $this-&gt;pagination-&gt;initialize($config);
  ...
  $data['owns'] = $this-&gt;rating_model-&gt;getOwned($data['user'][0]['id'],$config['total_rows'],$config['per_page']);
  </code></pre>
  
  <p>In my model, I used simple <code>limit</code>:</p>
  
  <pre><code>public function getOwned($user,$limit,$start) {
      $this-&gt;db-&gt;limit($limit,$start);
      ...
  </code></pre>
  
  <p>Links and all works fine, but they doesn't work. I am getting an url like <code>http://site.com/index.php/user/1/tomek/2</code>, but items are still intact. Where is my mistake?</p>
  
  <p>edit> complete controller code:</p>
  
  <pre><code>public function index($user = null) {
          $session_data = $this-&gt;session-&gt;userdata('user_data');
          $this-&gt;db-&gt;cache_off();
  
          if($session_data) :
  
              $this-&gt;load-&gt;helper(array('form', 'url'));
              $this-&gt;load-&gt;library('pagination');
              $this-&gt;load-&gt;model('user_model');
              $this-&gt;load-&gt;model('rating_model');
              $this-&gt;load-&gt;model('games_model');
  
              if($user) {
                  $user = $user;
              } else {
                  $user = $session_data['id'];
              }
  
              //vars
                  $data['user'] = $this-&gt;user_model-&gt;getUser($user);
                  $data['title'] = $data['user'][0]['nick'].' · Profil użytkownika';
                  $data['age'] = $this-&gt;user_model-&gt;getAge($data['user'][0]['birth']);
                  $data['sex'] = $this-&gt;user_model-&gt;getSex($data['user'][0]['sex']);
  
                  $config['base_url'] = site_url('user').'/'.$user.'/'.$data['user'][0]['nick'].'/';
                  $config['total_rows'] = $this-&gt;rating_model-&gt;countOwned($user);
                  $config['per_page'] = 4;
                  $config['enable_query_strings'] = true;
                  $this-&gt;pagination-&gt;initialize($config);
  
                  $data['pages'] = $this-&gt;pagination-&gt;create_links();
  
                  $data['rates'] = $this-&gt;rating_model-&gt;countRates($user);
                  $data['rates2'] = $this-&gt;rating_model-&gt;countGrades($user);
  
                  $data['developers'] = $this-&gt;games_model-&gt;getDevelopers();
                  $data['genres'] = $this-&gt;games_model-&gt;getGenres();
                  $data['platforms'] = $this-&gt;games_model-&gt;getPlatforms();
  
                  $data['nowPlaying'] = $this-&gt;rating_model-&gt;getNowPlaying($data['user'][0]['id']);
  
                  $data['owns'] = $this-&gt;rating_model-&gt;getOwned($data['user'][0]['id'],$config['total_rows'],$config['per_page']);
  
                  //load
                  $this-&gt;template-&gt;load('template','theme/yourAccount/main', $data);
  
          else :
  
                  $this-&gt;load-&gt;view('unlogged');
  
          endif;
      }
  </code></pre>