0
votes

This seems to be a pretty straight forward change, however it's not matching the URL and none of the answers on stackoverflow seem to address this simple use of redirect rules. I believe it has something to do with the '?id=XXXX' portion of the URL.

We have some old versions of pages, which I am trying to add redirects to the new version of the pages.

Here's an example of my rules:

<rule name="old_Page" stopProcessing="true">
    <match url="^Page.aspx?id=12345"/>
    <action type="Redirect" url="http://www.example.com/newPage.aspx"    redirectType="Permanent" />
</rule>

Any help would be most appreciated.

1

1 Answers

0
votes

I used a different method to create Static Redirects in the web.config from this article:

https://www.iis.net/learn/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module

<rewrites>
    <rules>
        <rule name="Redirect Rule" stopProcessing="true">
            <match url=".*" />
            <conditions>
               <add input="{StaticRedirects:{REQUEST_URI}}" pattern="(.+)" />
            </conditions>
            <action type="Redirect" url="http://www.example.com{C:1}" appendQueryString="False" redirectType="Permanent" />
        </rule>         
    </rules>
    <rewriteMaps>               
        <rewriteMap name="StaticRedirects">
            <add key="Page.aspx?id=12345" value="/newPage.aspx" />          
        </rewriteMap>       
    </rewriteMaps>
</rewrites>

I can add as many redirects as I like in the rewrite map section by adding additional keys.