« Previous Next »

Answered Thread: Query string with multiple parameters

Last post 02-26-2009 12:58 PM by ruslany. 1 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (2 items)

Sort Posts:

  • 02-25-2009, 11:46 PM

    • lamaks
    • Not Ranked
    • Joined on 02-26-2009, 4:23 AM
    • Posts 1

    Query string with multiple parameters

    Hi,

    I have the scenario where multiple query parameters should be transformed to the different values. For example:

    http://host/page.aspx?p1=1&p2=2 transforms to http://host/path/m1/m2

    Where 1 transforms to m1 and 2 transforms to m2 based on the rewrite map tables.

    Parameters p1 and p2 are mandatory and can be in any order within the query string.

    How the query parameters can be fetched from the {QUERY_STRING} so the following pseudo action will work? Apparently regex with named groups is not supported.

    host/path/{rewriteMap1:{C:p1}}/{rewriteMap2:{C:p2}}

    Thanks

     

  • 02-26-2009, 12:58 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 7:38 PM
    • Redmond, WA
    • Posts 664

    Answered Re: Query string with multiple parameters

    If parameters can be in any order within the query string then you can try something like this:

    <rule>
    <match url="page\.aspx$" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="(?:^|&amp;)p1=(\d+)(?:&amp;|$)" />
        <add input="##{C:1}##_{QUERY_STRING}" pattern="##([^#]+)##_.*p2=(\d+)(?:&|$)" />
    </conditions>
    <action type="rewrite" url="host/path/{rewriteMap1:{C:1}}/{rewriteMap2:{C:2}}" />
    </rule>

    http://ruslany.net
Page 1 of 1 (2 items)
Microsoft Communities