1

I'm upgrading a Win 2003 box that uses Helicon's ISAPI_REWRITE over to a Win 2012 box (IIS 8.5) and looking at URL Rewrite 2.0 as the replacement.

One of my rules was recursive to allow an unlimited number of key/value pairs in the URL to be converted into the querystring values passed to the .aspx page.

URL Rewrite 2.0 has a handy import feature but it doesn't like the flag that made the rule recursive. I say recursive in that it processed one pair of key/value into a rewrite then passed that rewrite back into the engine where it was picked up by the same rule if there were more pairs, or into a final rule where all that rewriting was passed to its final form.

Here are my rules from Helicon - which I understand were similar in syntax to the apache rules, with exception of the flag that made it recursive (NS)

#Allow for /flag/key/value/key/value for .NET - using /mci as the flag
RewriteRule ([^?]*/mci)(\?[^/]*)?/([^/]*)/([^/]*)(.*/[^?/]+\.html) $1(?2$2&:\?)$3=$4$5 [NS,I]
RewriteRule ([^?]*)/mci(\?[^/]*)?/([^?/]+)\.html $1/$3.aspx$2 [I,L]

This allowed:

http://www.whatever.com/subdir/mci/g/5/i/200/c/cookies/blah.html

To be rewritten into:

http://www.whatever.com/subdir/blah.aspx?g=5&i=200&c=cookies

URL Rewrite 2.0 complains about the (NS) flag but I cannot find another setting that says "pass this rewrite back through the rule engine from the beginning after you're done with this rule" - or preferred "keep processing this rewrite until it no longer matches the pattern."

Any help appreciated. I saw I could write my own provider but I'd think this sort of solution would be needed by more than just me.

imukai
  • 638
  • 1
  • 7
  • 17
  • I don't think there is a straightforward way to convert this syntax for URL Rewrite. However, you may consider using ISAPI_Rewrite 3 or Helicon Ape on win2012. – TonyCool Aug 12 '15 at 01:58
  • I wasn't sure if ISAPI 3 worked under IIS 8.5. I suppose it does but I may also end up writing my own Provider for this IIS one - if I can figure out the proper c# regex to convert my /key/value../key/value/file.html into the proper file.aspx?key=value..&key=value. I'm not so sure the pattern used in the Helicon config file directly translates into C#. I'll look more after some sleep. – imukai Aug 13 '15 at 01:46

0 Answers0