File: D:/bin/iirf/tests/transformurlsegmentstoqueryparamsiteratively/IIRF.ini
# IsapiRewrite4.ini
#
# example ini file
#
# Fri, 11 May 2007 12:28
#
RewriteLogLevel 5
# -------------------------------------------------------
# This rule shows how to transform a URL into a query string, piecewise, iteratively.
# In this case, each path segment in the original URL (entered in the browser)
# becomes the value of a query param, which is named "v". That is to say, the result
# is a URL with a multiply-valued query param named v, it has many values. The
# receiving app (in this case index.cfm) needs to iterate through all the v values.
# Presumably they will have positional significance. In other words
# index.cfm?v=9&v=123 will mean something different from index.cfm?v=123&v=9. But
# that is up to the application, isn't it?
# The way it works - we rewrite once for the first case, in order to get the question
# mark. Subsequent passes through the filter will add query params as necessary.
# Then there is the final case. Run this test and examine the output, and the
# meaning will be clearer.
# handle case with no query string . This rule fires the first time through.
RewriteRule ^/(?!index\.cfm)([^\?\/]+)/([^\?]+)$ /$2?v=$1
# handle case with existing query string. This rule fires potentially multiple times.
RewriteRule ^/(?!index\.cfm)([^\?\/]+)/([^\?]+)\?(.+)$ /$2?$3&v=$1
# handle case with one more segment. This fires once (last).
RewriteRule ^/(?!index\.cfm)([^\/]+)\?([^\?]+)$ /index.cfm?$2&v=$1 [L]
# handle edge case, where there is only one segment. This fires once (last).
RewriteRule ^/(?!index\.cfm)([^\/]+)$ /index.cfm?v=$1 [L]