Search code examples
asp.net-web-apivisual-studio-2015iis-expressiis-8

Http Redirect within web.config using wildcards not working


My need is to tell IIS, within the web.config to ignore some URLs and to send a HttpRedirect to the client.

To do so, I added the following magic into web.config :

<system.webServer>
    <httpRedirect enabled="true" httpResponseStatus="Temporary" exactDestination="true"> 
        <add wildcard="*/iac*; " destination="http://someServer.smthg.be/iac$S$Q" />
    </httpRedirect>
</system.webServer>

When I try to make a request, to eg ´myserver/iac/john?doe=hello´ I only receive a 404 not found instead of the 302 I expected.


Solution

  •     <rewrite>
            <rules>
                <clear />
                <rule name="test" stopProcessing="true">
                    <match url="^iac/(.*)" />
                    <action type="Redirect" url="http://someServer.test.be/iac/{R:1}" appendQueryString="true" redirectType="Temporary" />
                </rule>
            </rules>
        </rewrite>