Friday, July 01, 2011

301 permanent redirect using IIS

Here's a quick post describing how to place a 301 permanent redirect on a Microsoft IIS web server; specifically IIS6. On a Microsoft server, you can do a HTTP 301 Permanent Redirect two ways by using:
  • Javascript or Visual Basic code within your ASP page or
  • server administrative tools (the IIS management server console, iis.msc)
This is different from a Linux box, where you can use not only code or Apache to do the 301, but you can also take advantage of the .htaccess file for redirects.

Since the page I was trying to redirect was an HTML page, I wasn't able to put in any VB or Javascript code to perform the redirect. If I was using an ASP page, I could use some VB code like this:
< %@ Language=VBScript %>
< %
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,

Instead, I used the IIS management console to edit the attributes of the file to permanently redirect the destination location of the file. In the example below, I have right-clicked on the Properties of a web resource available to IIS (a file under the wwwroot), have input my other blog "" as the destination URL and checked "a permanent redirection for this resource."

Lo and behold, this works..I am redirected to the proper location (shown below). However, when I use Firebug to inspect how the server is doing the redirects, I find that Firebug shows a "301 error" for the response code:

To confirm that it wasn't Firebug misinterpreting the response from the server, I used this site to confirm the response code:
Using the internetofficer site's redirect checker, I found that the redirect checker showed the same response from the IIS server. So Firebug wasn't reporting incorrect information.

Finally, after a bit of googling, it seems that the "301 error" is just the way that the IIS server responds to the 301 permanent redirection setting. This is confusing, non-standard terminology, as it caused me to think that I had implemented the redirect incorrectly. Perhaps Microsoft will fix this in the future.

anyway..Happy 4th of July!

1 comment:

Andy Robert said...

Hi Cocsod,
Good article! Thank you so much for sharing this post. Your views truly open my mind.

Hadoop map

Feel free to drop me a line or ask me a question.