asp.netiisurl-rewritingurlrewriter

Url rewriting question


This is my rule set up in web.config:

   <rule name="RedirectPopups" stopProcessing="true">
              <match url="^webforms/visitor/popup/*" />
              <conditions>
                <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                <add input="{QUERY_STRING}" pattern="^([^=&amp;]+)=([^=&amp;]+)$" />
              </conditions>
              <action type="Redirect" url="jwelery/INEEDTHEPAGEVARIABLEHERE/{C:1}/{C:2}" appendQueryString="false" redirectType="Permanent" />
            </rule>

Basically I have my popups in webforms\visitor\popup. I want to write a rule that when any page is request within this popup directory. It gets redirected to some custom url.

For Eg.

If user requests webforms/visitor/popup/HelloWorld.aspx?a=1

He should be redirected to jwelery/HelloWorld/a/1

I just need the solution for what should I write in "INEEDTHEPAGEVARIABLEHERE" in Redirect action. Is there any special variable that I can use? I am using IIS7

Thanks.


Solution

  • Why don't you use

    <match url="^webforms/visitor/popup/([a-zA-Z0-9]+).aspx\?([a-zA-Z0-9]+)=([a-zA-Z0-9]+)$" />
    <action type="Rewrite" url="jwelery/{R:1}/{R:2}/{R:3}" />
    

    ?