title: Htaccess : multiple parameters and nested parentheses
body: <p>I've got some project where I redirect every request on <code>index.php</code>, with various <code>GET</code> parameters.</p>
  
  <p>Currently, I'm using this kind of htaccess (this is only an extract, and I changed parameters name to <code>a, b, c...</code>, in order to simplify the problem) :</p>
  
  <pre><code>RewriteRule ^([\w-]+)\.html$                   index.php?a=$1 [L]
  RewriteRule ^([\w-]+)/([\w-]+)\.html$          index.php?a=$1&amp;b=$2 [L]
  RewriteRule ^([\w-]+)/([\w-]+)/([\w-]+)\.html$ index.php?a=$1&amp;b=$2&amp;c=$3 [L]
  (...)
  </code></pre>
  
  <p>It works (well), but I was thinking about a way to minify those lines into a single one.
  <strong>The idea is to have some nested parentheses to 'generate' all <code>GET</code> parameters</strong>, but it seems it won't work as easily as I thought.</p>
  
  <p>Here is what I've made so far :</p>
  
  <pre><code>RewriteRule 
      ^(?:([\w-]+)\/)*([\w-]+)\.html$ 
      index.php?a=$1&amp;b=$2&amp;c=$3&amp;d=$4&amp;e=$5&amp;f=$6&amp;g=$7&amp;h=$8&amp;i=$9 [L]
  </code></pre>
  
  <p><code>GET</code> result for the url <code>http://website.com/1/2/3/4/5/6/7/8/9.html</code> :</p>
  
  <pre><code>array(9) { 
     ["a"]=&gt; string(1) "8" 
     ["b"]=&gt; string(1) "9" 
     ["c"]=&gt; string(0) "" 
     ["d"]=&gt; string(0) "" 
     ["e"]=&gt; string(0) "" 
     ["f"]=&gt; string(0) "" 
     ["g"]=&gt; string(0) "" 
     ["h"]=&gt; string(0) "" 
     ["i"]=&gt; string(0) "" 
  }
  </code></pre>
  
  <p>Instead of get <code>a=1</code>, <code>b=2</code>, <code>c=3</code>... I only receive the two last parameters. Notice that the <code>RewriteRule</code> is executed, then I know my regex match.</p>
  
  <p>Any idea ?</p>