File: D:/bin/iirf/tests/transformurlsegmentstoqueryparamsiteratively2/IIRF.ini
# IsapiRewrite4.ini
#
# This ini file shows how to transform a URL into a query string, piecewise, iteratively.
# In this case, path segments come in pairs. The first of the pair is the param
# name, the second of the pair is the param value. So, a pair of path segments in
# the request URL like .../a/b... will result in a rewrite of ?a=b.
#
#
# Fri, 11 May 2007 12:28
#
RewriteLogLevel 5
# -------------------------------------------------------
# handle case with no query string . This rule fires the first time through.
RewriteRule ^/(?!help\.cfm)([^\?\/]+)/([^\?\/]+)/([^\?]+)$ /$3?$1=$2
# handle case with existing query string. This rule fires potentially multiple times.
RewriteRule ^/(?!help\.cfm)([^\?\/]+)/([^\?\/]+)/([^\?]+)\?(.+)$ /$3?$4&$1=$2
# Handle the case with one more pair of segments. This fires once (last).
# It fires when there is an even number of segments.
RewriteRule ^/(?!help\.cfm)([^\?\/]+)/([^\?\/]+)\?([^\?]+)$ /help.cfm?$3&$1=$2 [L]
# Handle the case with exactly one pair of segments. This fires once (last).
RewriteRule ^/(?!help\.cfm)([^\?\/]+)/([^\?\/]+)$ /help.cfm?$1=$2 [L]
# Handle the edge case, where there is an odd number of segments (invalid input URL)
# This fires once, after all the other pairs have been parsed. In fact the filter
# cannot know that there is an odd number of segments until it does all the matching.
# So at the end we see, we have one left over segment, and we
# redirect to a 404 page.
RewriteRule ^/(?!help\.cfm)([^\/\?]+)\?([^\?]+)$ /ResourceNotFound.cfm [L]
# Handle the edge case where there is only one segment.
RewriteRule ^/(?!help\.cfm)([^\/\?]+)$ /FoundOnlyOneSegment.cfm [L]