2

Trying to figure out how to do wildcards for querystrings. Right now this works, but it has to be an exact match.

I have this rewrite rule.

            <rule name="Redirect rule1 for Redirects ReSv">
            <match url=".*" />
            <conditions>
            <add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
            </conditions>
            <action type="Redirect" url="{C:1}" appendQueryString="true" />
            </rule>

My rewrite maps are like:

<rewriteMaps>
    <rewriteMap name="Redirects">
            <add key="/contact-us.aspx" value="/contact/" />
            <add key="/contact-us/request-information.aspx" value="/contact/" />
    </rewriteMap>
</rewriteMaps>

Trying to get something like this: /contact-us.aspx?q=t&1=2

To redirect to: /contact/ And include the querystring? so.. /contact/?q=t&1=2

bb2j3z
  • 63
  • 1
  • 5

1 Answers1

2

Please us {URL} variable instead of {REQUEST_URI}. Then Rewritemap will be able to wildcard the query string.

 <rule name="Redirect rule1 for Redirects ReSv" stopProcessing="true">
            <match url=".*" />
            <conditions>
                        <add input="{Redirects:{URL}}" pattern="(.+)" />
            </conditions>
            <action type="Redirect" url="{C:1}" appendQueryString="true" redirectType="Permanent" />
            </rule>

enter image description here

Jokies Ding
  • 3,374
  • 1
  • 5
  • 10