Search code examples
http-redirectiisweb-confighttp-status-code-301

Simple 301 Redirect in Web.Config (IIS)


I've browser a lot of similar questions here, but most have complicated parameters associated with them. I'm just looking to 301 redirect one link to another on the same domain. The to and from links are very specific, so I don't need to account for any wildcards.

In web.config what would be the appropriate way to 301 redirect /locations/100-denver to /locations/denver?


Solution

  • <configuration>
        <system.webServer>
            <rewrite>
                <rewriteMaps>
                    <rewriteMap name="Redirects">
                        <add key="/test.aspx" value="/test2.aspx" />
                        <add key="/aboutus.aspx" value="/about" />
                    </rewriteMap>
                </rewriteMaps>
            </rewrite>
        </system.webServer>
    </configuration>
    

    I was just researching a similar subject and found this answer on another page: enter link description here