Encoded ampersand gets converted to regular ampresand

Oct 26, 2010 at 2:06 PM

I have a URL like: http://www.example.com/J+%26+M+AC_AIR+CONDITIONING+CONTRACTORS_ppt8.asp  That I'm using the following rule to rewrite:  RewriteRule ^(.*)/(.*)_(.*)_(.*).asp$  $1/New.asp?l=$2&h=$3&b=$4 [I,QSA,U]

It all works fine except in the case where %26 appears in the original URL.  It is getting converted to a regular ampersand when the RewriteRule takes place.  So, in the log I get:  /New.asp?l=J+&+M+AC&h=AIR+CONDITIONING+CONTRACTORS&b=ppt8  It now opens the New.asp but it can't correctly read the l and h values using QueryString.  It gets 'J ' for the h and nothing for l because there is essentially an extra &.  Is there something I should be doing differently?  I saw workitem:9910 but that is a slightly different scenario.  I don't see how I can add another % before %26.  I also saw the docs so I know it is treating %26 as a recently evaluated RewriteCond.  Another weird thing is that the browser address bar still shows the escaped ampersand as %26.  It's only in the iirf log that it shows %26 as &.


Oct 26, 2010 at 11:27 PM

I think it might be the same issue I posted about yesterday: http://iirf.codeplex.com/Thread/View.aspx?ThreadId=232262

Oct 29, 2010 at 9:42 PM

I did some digging in the source code and found the UrlDecoding setting.  Which led me to this forum post here: http://iirf.codeplex.com/Thread/View.aspx?ThreadId=209993  Setting this to off might be our answer.  Although, it's leading to other problems for me.  Not to mention the ones Cheeso mentions in the thread.  I guess my remaining question is why is the ampersand displayed as & in the log but things like underscores show up as %5F and not _.  I would expect the ampersands to be %26.  It is doing something special with %N but i can't seem to turn it off.  I tried setting CondSubstringBackrefFlag @ so it wouldn't use %.


Nov 1, 2010 at 5:57 PM

Thanks Barker, UrlDecoding OFF seems to do the trick for me.