URL Rewrite 301 Redirect For a Single Page

Want to set up a 301 redirect for a certain single page on your site to send users to a different URL?

Below is a very simple web.config file I created on an IIS7 server to demonstrate performing this action. The rule looks for a URL of http://<yourdomain.com>/folder1/default.aspx and, if found, returns an HTTP Status code of 301 and then sends users instead to the URL of http://www.TheDestinationSite.com.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="RedirectSingleURL" patternSyntax="ExactMatch">
                    <match url="folder1/default.aspx" />
                    <action type="Redirect" url="http://www.TheDestinationSite.com/" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

This sample should work on a site hosted on any version of IIS7 or higher, like the Managed Windows Hosting plans over at OrcsWeb or the Discount Windows Hosting plans at Cytanium.

Happy hosting!

No Comments