ASP.NET / IIS7 Url Rewrite maps not working

asp.netiis-7url-rewriting

I've followed the instructions Learn IIS's webpage for adding static redirects with a rewrite map for my asp.net application.

The following is the config:

<rule name="Redirect rule1 for Information" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{Information:{REQUEST_URI}}" pattern="(.+)" />
    </conditions>
    <action type="Rewrite" url="{C:1}" appendQueryString="true" />
</rule>

And

<rewriteMaps>
    <rewriteMap name="Information">
        <add key="/Information/CorporateSales.aspx"
             value="/KB/Information/CorporateSales" />
        <add key="/Information/ComputerRepair.aspx"
             value="/KB/Information/ComputerRepair" />
    </rewriteMap>
</rewriteMaps>

This was even originally created by the wizard in IIS's manager for using rewrite maps.

So the idea is that /Information/CorporateSales.aspx –> /KB/Information/CorporateSales with a 301 redirect (MOVED PERMANENTLY).

However I'm just getting the original aspx page (Which we're removing later) loading. I've even deleted the file incase it was defaulting to an existing resource, and with that i just get a plain 404 without the redirect.

Anyone have an idea?

Let me clarify something:

Rewrite module works, it's installed and running. My standard regex rules work nicely. But my rewrite map does not.

Best Answer

This article http://www.iis.net/learn/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module and code below worked for me.

<rewrite>
    <rules>
        <rule name="Redirect rule1 for RedirectURLs">
            <match url=".*" />
            <conditions>
                <add input="{RedirectURLs:{REQUEST_URI}}" pattern="(.+)" />
            </conditions>
            <action type="Redirect" url="{C:1}" appendQueryString="false" />
        </rule>
    </rules>
    <rewriteMaps>
        <rewriteMap name="RedirectURLs">
            <add key="/privacy.php" value="/privacy" />
        </rewriteMap>
    </rewriteMaps>
</rewrite>
Related Topic