title: Apache mod_rewrite path name as query parameters?
body: <p>I want to use Apache's <code>mod_rewrite</code> in order to be able to take each folder of a path as a particular query parameter, for example consider the following:</p>
  
  <p><strong>Basic example</strong></p>
  
  <p>Url requested: <code>http://domain.com/shoes/prada/image-1/</code></p>
  
  <p>Page served: <code>http://domain.com/?cid=shoes&amp;bid=prada&amp;pid=image-1</code></p>
  
  <p>In this scenario, there are 3 sub-folders requested (<code>/shoes/</code>, <code>/prada/</code> then <code>image-1</code>), so the first sub-folder is passed in the actual page served as <code>cid</code>, the second as <code>bid</code> and the third as <code>pid</code>.</p>
  
  <p><strong>Full example</strong></p>
  
  <p>However, I would also like it to serve a particular page depending on the number of sub-folders requested, e.g.</p>
  
  <p>Url requested: <code>http://domain.com/shoes/prada/</code></p>
  
  <p>Page served: <code>http://domain.com/shop.php?cid=shoes&amp;bid=prada</code></p>
  
  <p>So far all I've managed to find is regex based matching for <code>mod_rewrite</code> but my path's will vary a lot, which is why I would like to have conditions based on the number of folders accessed (please note, I'm not that good with regex - I reckon a wildcard character would help with this, but I wouldn't be sure where to start).</p>
  
  <p>Any help on this would be greatly appreciated! This is pretty long winded, so if you need any more info for clarifying, please let me know!</p>