IIRF Not Passing Complete String Variable

Topics: Developer Forum
Apr 1, 2011 at 6:17 PM

I have a regex that passes a string variable through IIRF as follows:


Match: item/(e)/([0-9]+)/(\S+)

 Rewrite: /item/$1/item.cfm?id=$2&title=$3

On the other side of the rewrite my #3 variable only shows up as "SOME" and the rest of the string is truncated. IIRF is stripping out everything after the last character of the first word in the string.

Any thoughts how I could prevent this and get the whole string to show up after the rewrite?

Actual Rule: RewriteRule item/(e)/([0-9]+)/(\S+) /item/$1/item.cfm?id=$2&title=$3 [I]

Apr 2, 2011 at 3:38 PM

Yes -

I believe that what you're seeing is due to a misunderstanding on your part. The incoming URL gets URL decoded before processing by the IIRF rules. You can turn this off (see the UrlDecoding directive, I believe), or you can modify your regex to not capture only non-whitespace characters. 

Here's what I mean: The \S in your regex says "only non-space" if I am not mistaken.  But when the %20 in the incoming URL gets decoded, it turns into a space, which means your regex captures up to, but not including, the first space. hence, "SOME"  .  To fix, don't use \S, or turn off URL Decoding in IIRF.

If you turn on IIRF logging and sniff through the log, you will see clear evidence of the behavior I'm describing.  The Log is sort of verbose, and it might look intimidating, but there's good information in there if you are seeking insight into how your rules are operating.

good luck.