title: CakePHP 3.x: routes with query string
body: <p>Named parameters were finally removed with CakePHP 3. Now I want to know if there is an easy way to create routes that use the query string.</p>
  
  <p>Now I have:</p>
  
  <pre><code>http://mysite/posts?page=2
  </code></pre>
  
  <p>While I would like:</p>
  
  <pre><code>http://mysite/posts/2
  </code></pre>
  
  <p>I have read the <a href="http://book.cakephp.org/3.0/en/development/routing.html" rel="nofollow">CakePHP book</a>, but I have not found useful examples.</p>
  
  <p>When I say "an easy way", I mean precisely by using a route, not the controller or the paginator.</p>
  
  <hr>
  
  <p><strong>EDIT:</strong>
  I know I can do this:</p>
  
  <pre><code>$routes-&gt;connect('/posts/:page', ['controller' =&gt; 'Posts', 'action' =&gt; 'index'], ['page' =&gt; '[0-9]+', 'pass' =&gt; ['page']]);
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public function index() {
      if($this-&gt;request-&gt;param('page'))
          $this-&gt;request-&gt;query['page'] = $this-&gt;request-&gt;param('page');
  
      //other code...
  }
  </code></pre>
  
  <p>But in this way I need:</p>
  
  <ol>
  <li>to modify my controller;</li>
  <li>to modify the paginator (the new url works, but it is not used automatically by CakePHP).</li>
  </ol>