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, Gumbo answered a similar question with a sort of "loop" that would allow for something like that.
However, as I believe he pointed out at the time, and I'll point out to you now, doing so with mod_rewrite
is really not a good idea. It is much better to just have mod_rewrite
rewrite your URL to your script:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/models/.*$ /models [NC,L]
...Then parse the original REQUEST_URI
value to extract the information that you want. Your scripting language of choice is a much more suitable tool for this task than mod_rewrite
is.
As far as mending your current rule, I think perhaps your request to the server had a trailing slash? Since your (.*)
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:
RewriteRule ^/models/([^/]*)/([^/]*)/([^/]*)/([^/]*)$ /models?$1=$2&$3=$4 [NC,L]
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.