Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>With a bit more information, it likely is possible to take your URLs with an arbitrary number of key-value pairs and convert them to a query string to pass to your script. If I remember correctly, <a href="https://stackoverflow.com/users/53114/gumbo">Gumbo</a> answered a similar question with a sort of "loop" that would allow for something like that.</p> <p>However, as I believe he pointed out at the time, and I'll point out to you now, doing so with <code>mod_rewrite</code> is really not a good idea. It is much better to just have <code>mod_rewrite</code> rewrite your URL to your script:</p> <pre><code>RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/models/.*$ /models [NC,L] </code></pre> <p>...Then parse the original <code>REQUEST_URI</code> value to extract the information that you want. Your scripting language of choice is a much more suitable tool for this task than <code>mod_rewrite</code> is.</p> <p>As far as mending your current rule, I think perhaps your request to the server had a trailing slash? Since your <code>(.*)</code> groupings can match anything (or nothing), they'll greedily consume the first slash as part of the key name if you have three other slashes following it. The simple solution would be to not match slashes in your capture group:</p> <pre><code>RewriteRule ^/models/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /models?$1=$2&amp;$3=$4 [NC,L] </code></pre> <p>Note that if you're trying to do this as a series of six separate rules, you're going to run out of backreferences, since the most you can get (that you define) here is 9.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload