Adding a 301 Redirect in IIS for Individual Pages with Non-ASPX Extensions

Are you migrating from a non-ASP.NET web site to an ASP.NET based Content Management System and don't want to lose inbound links from Google or other sites?  There is an easy way to do this in IIS!

If you're looking for redirecting domains or www to non-www urls, please take a look at an article I wrote a few months back: How to 301 Redirect example.com to www.example.com in IIS.

redirect_1Now that Google is pulling out key links to display with your search results, migrating a new site could be disaster if a user clicks one of those links and they get a 404 or an error page.

See the links under the Twitter search result to the right.  Those are key entry points to your site.

Now, what if you're using ASP.NET and those links point to a .php or .htm extension?  No problem.  IIS can handle it.

How to do 301 redirects on a page by page basis in IIS:

1. Open the Internet Information Services (IIS) Manager.

redirect_21

You may need to remote desktop to the server to open the IIS Manager.

2.  Find the web site under the "Web Sites" folder that is the new web site that will have the redirects.

OK, now we will come back to IIS in a sec, but first we need to create some files.

3. Browse to the new web site location on disk and create a file with the correct name and path from the old web site.

For example, if the old web site has an incoming link to http://www.mysite.com/about-us.htm then the file name to create would be "about-us.htm".  The path is just in the root on the ASP.NET web site.

If the incoming link is pointing to http://www.mysite.com/trips/mt-hood.htm, then you would create a directory "trips" and then the file name would be "mt-hood.htm".

Now that you have created the files that correspond to the old site links, we can set up the redirect.

4. Browse to the new file in the IIS Manager.

When you click on your new web site in IIS, you should see a file listing on the right side.

If you are using Windows Server 2008 your IIS may look a little different on the right side:

redirect_3

In this case, just click the "Content View" tab on the bottom.

You should now see the files that comprise your new web site.

5. Find the file you created and setup the re-direct.

NOTE: you may need to follow these steps in Windows Server 2008 to allow HTTP Redirection - Enabling 301 redirects on IIS 7 on Windows server 2008

Right-click on the new file and select "Properties"

redirect_4

Then in the Properties dialog on the "File" tab, select the "A redirection to a URL" radio selection.

Type or paste in the URL on the new site that contains that information.

Check the "The exact URL entered above" and "A permanent redirection for this resource".

redirect_5

Click OK.

If you are using Server 2008 (IIS 7):

Right-click on the file in the "Content View" and select "Switch to Features View"

redirect_6

Select the "Http Redirect" item in the list of actions.

redirect_7

Click the "Redirect requests to the destination" checkbox.

Add the new URL location in the URL text box.

Check the "Redirect all requests to exact destination" check box.

Select the "Permanent (301)" item in the "Status code:" drop down box.

redirect_8

Apply the Changes

redirect_9

That's it!  Now test that the redirect worked and continue with the rest of the inbound links to redirect.

Author

Jason Prothero

comments powered by Disqus
back to top