Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
I am working on a 301 redirect rule that is suppossed to work like this:
/(A(kdkeidks))/abc/abc/page.aspx?parm=abc&parm=123 should flip to /result

so that means that www.domain.com/(A(kdkeidks))/abc/abc/page.aspx?parm=abc&parm=123 should be www.domain.com/result

This web.config value below doesn't work because somehow it doesn't like the extra parentheses in the URL. I need to find a way to be able to handle this, including these characters on the domain "?" and "&".

<rule name="URLRedirectionRule" stopProcessing="true">
<match url="(.*)" />
      <conditions>
               <add input="{URLRedirectionProvider:{URL}}" pattern="(.+)" />
       </conditions>
<action type="Redirect" url="{C:1}" appendQueryString="true" />
</rule>

Any feedback is greatly appreciated.
Posted

1 solution

I resolved the issue doing the following:

XML
<rule name="301 Rule" stopProcessing="true">
<match url="^([a-zA-Z0-9_'-]+)/([^)]+)$" />
<conditions>
<add input="{QUERY_STRING}" pattern="parm1=89" />
<add input="{QUERY_STRING}" pattern="parm2=63" /> 
</conditions> 
<action type="Redirect" url="http://www.domain.com/result" redirectType="Permanent" appendQueryString="false" />
</rule>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900