Quantcast

How to set up a 301 Redirect on IIS, Non-www Domain Name to www Domain Name

Get the WebProNews Newsletter:
[ Business]

To further elaborate on a article I wrote: 301 Redirects And Domains With And Without WWW, I wanted to discuss the actual implementation of a 301 redirect on IIS.

I was recently asked by a client on detailed instructions on how to properly set up a 301 redirect on IIS to redirect a non-www domain to the www domain. This cannot be done in the IIS control panel because when set up the IIS will force the website to loop to itself, thus never loading in a browser properly. In Apache this can be done with a couple of simple lines of code in the .htaccess file. In IIS it is much more difficult…but not impossible.

First off, to be clear, you have two options:

1. You can create a new IP based web site in Internet Services Manager using the mydomainname.com address. You will now have two websites set up in IIS one for www.mydomainname.com and one for mydomainname.com. of course not everyone has an extra IP to do this. If you don’t you can use the option below.

2. You can add another website on the same IP with the host header value (virtual website) option. The second website would be mydomainname.com under the host header domain of www.mydomainname.com.

Once one of these are set up you see both will return a 200 server response when checking the server headers. You can check your headers here:

http://www.seoconsultants.com/tools/headers.asp

Of course our next step would be to change the server response for mydomainname.com domain to show 301 redirection to www.mydomainname.com. Here is the code you should put in the NEW default home page file for mydomainname.com:

ASP:

< %@ Language=VBScript %>
< %
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", http://www.mydomainname.com
%>

After that check the server header here:

http://www.seoconsultants.com/tools/headers.asp

It should show a 301 response and then redirect to www.mydomainname.com.

Of course you could do this without creating a new website by using ISAPI_Rewrite, but this is not available on most hosting accounts. You could install it yourself, but once again not sure if the hoster will even support it for you. IIS can be very yucky sometimes, but using the instructions above you can implement the 301 redirect your looking for.

Jaan Kanellis, is owner and operator of an independent SEO consulting company, www.KBKMarketing.com. Jaan Kanellis distributes his articles through the newly created SEO blog, www.JaanKanellis.com. Feel free to visit these websites and contact him if interested in his consulting services.

How to set up a 301 Redirect on IIS, Non-www Domain Name to www Domain Name
Top Rated White Papers and Resources
  • http://www.rankbetterseo.com/ seo web design

    Great web design and programming article. Look forward to more SEO and web design articles from you Jaan.

  • http://sn.vc SNVC

    This is definitely a good guide. Thanks for this.

     

  • http://www.articleblip.com/article/news/weird-news weird news

    Thanks for the great information Jaan

  • http://www.answeraddict.com/faq/gaming-questions game questions

    Thanks for the great info

  • http://easttexasautos.com Trey Brister

    Here is a good solution for ASP users that does not require multiple hosting accounts.

    http://www.easttexasautos.com/autoblog/?p=3

    PS: I linked to this URL in the post. Can I get a reciprocal link?

  • http://domain-daily.com/ whoislookup

    Thanks for the good guide.

  • http://www.pokerfreebankrolls.com free poker bankroll

    Hy,

    I read your tutorial about how to redirect on IIS. This code:
    < %@ Language=VBScript %>
    < %
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", http://www.mydomainname.com
    %>
    should i introduce in my html pages? Can you tell me how exactly to do this redirect? For two days i search about this problem and until now nothing… I remember i only have .html static pages. Can i make a such redirection?
    Thanks!

  • http://www.3amgroup.com/OrlandoSearchEngineOptimization/index.html Orlando Seo

    We’ve done most (95%) of our SEO on Linux servers, and didn’t know how to solve this problem on a windows based server. Thanks for the help.

  • http://lukedurrant.com Luke Durrant

    Much easier to do it this way
    http://www.xoc.net/works/tips/domain.asp

  • http://www.a1bs.com/ Stephen

    Thank you for your great article Jaan very long time I’m looking for this to do for my website

  • http://www.noyasystem.com ramin

    I’m using Windows Server Panel.
    How can I setup IIS??

  • http://www.peruandarts.com Fabricio

    Hi, can anyone here share the code for asp.net because the code here doesn’t work with asp.net, thank you.

  • http://www.bigboot.com clive homewood

    This is useful information for anyone trying to redirect to pages or other sites. However it is down to the web designers or technical staff to implement. This can cause problems when you are unaware of all the back links to your site and all the search engine links. This is useful information for anyone trying to redirect to pages or other sites. However it is down to the web designers or technical staff to implement. This can cause problems when you are unaware of all the back links to your site and all the search engine links. A way round this is to use the IIS Redirect software from Bigboot software. This software allows the technical staff to install a isapi on the server and non-technical staff to monitor and add the redirects simply. Removing the cost of using expensive technical personal. The back links and failing search engine requests are captured and display using a simple pc application allowing non-technical staff to add or change rewired. This software can be found at HTTP://www.bigboot.com/iisredirect

  • http://www.webdigitalservices.com John

    Thanks for you guidance. Had a query regarding the second method to implement 301 non www to www redirect does that work perfectly or do i need to prefer the 1st method.