How To Set Up A 301 Redirect On IIS, Non-www Domain Name To Www Domain Name

How To Set Up A 301 Redirect On IIS, Non-www Domain Name To Www Domain NameTo 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: seoconsultants.com

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: seoconsultants.com

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.


Related Articles

  • Not To Be Banned By Google
    Strategic search engine optimization involves far more than keyword research, META tags and content. If you want to mange an SEO program, you need to be aware of any issue that can affect your success. Domain name management is one of the big factors. Effective domain name management is critical bec...
  • How to Choose Perfect Domain Name for your website?
    Worried for your Website Domain Name? Then not to worry!! Our complete guide will illustrate you the most perfect steps to choose domain name.
  • Domain Name Registration - Changing Your Website URL
    Domain name registration is the most important step to take when setting up a website, although not actually the first step. The first step to take is to choose a good domain name!
  • What is a domain name?
    The domain name is a unique name that identifies a web site. All domain names have 2 or more parts and are organized hierarchically with the more generic parts to the right. The domain hierarchy is presented by dots found in the domain name...
  • An Easy Way Not to Get Banned by Google
    Strategic search engine optimization involves far more than keyword research, META tags and content. If you want to mange an SEO program, you need to be aware of any issue that can affect your success. Domain name management is one of the big factors...
  • Redirect Url
    Occasionally, you may wish to have a redirect page that pauses for a few seconds before sending the visitor off to the destination. For example, there may be important text on the redirect page you wish the visitor to get a chance to read, or a banner ad to see.before proceeding. This redirect script
  • Easy Steps to Get a Domain Name and Hosting Account and Get Moving on the Internet
    You may be thinking of starting to build a presence on the internet, so where do you start?
  • Domain Name Search
    When you want to check who registered a particular domain name, you can perform a WHOIS lookup. This will allow you to lookup all data available in the pubic domain records. You can find the owner and thedetails of the domain.
  • How to Choose a Domain Name
    What is a domain name?
    Millions of domain names have already been registered and finding the perfect domain name will be tricky. Unless you have a deep pocket and bother to buy a very very brandable domain name, youll have a hard time getting the best domain.
  • The Cheapest Domain Names - What do you get for $1.99?
    There are several sites on the internet claiming to offer the cheapest domain names. If you look hard enough, you can find domain names for as low as $1.99 or $2.99 per year. So, whats the catch?

Contact Web Design Outsource and get started today

Need Website Designing, Development, Redesigning, Maintenance and SEO services or help growing your company's web presence? Request a free Quote Now.