Redirecting canonical names in IIS 7

Preface:  This procedure uses the domain example.com for illustrative purposes only.  You will want to substitute example.com for your own domain.  Also, if the images are too small, click on them to expand to full size.

When building a website, it is essential to plan for users that may try to access your site using www and non-www versions of your domain (www.example.com and example.com).  It is possible to just simply configure DNS to point both records to the same server and do nothing more, however this is not best practice.  Search engines that crawl your site will see two seperate sites with the exact same content, which can jeopardize your rankings.  Instead, we should be informing search bots to index the content at only one canonical URL.  We can accomplish this using a 301 redirect – this informs the bot that the URL to redirect from has permanently moved to the URL you are redirecting to (example: www.example.com to example.com)  This has the benefit of not only streamlining future indexes, but also informing search engines to change URLs for already indexed content to the new URL.

So how do we configure IIS to redirect traffic?

First, we need to ensure the IIS URL Rewrite Module 2.0 is installed from the IIS Website.

Next, ensure that we have both canonical names configured on the same web site in IIS by right clicking on the site and selecting “Edit Bindings”:

bindings_list

You should see a list of your canonical URLs: If the URLs are not all present, click the add button to add a binding.  Type the domain name in the Host Name field, and click OK.  Repeat this step until all canonical names are configured, then click Close:

add_binding_www

We then want to access the URL Rewrites plugin in the site dashboard.  Select Add Rule:

select_add_rule

Scroll down in the window of available options, and select Canonical domain name.

select_canonical_domain_name

If you want the www to always appear in the URL, select www.example.com.  If you do not want www in the URL, select example.com.

select_primary_hostname

Click ok, and you will see the CanonicalHostName1 rule created.  Double click if you would like to view the parameters.

view_rule_list

To test, open your web browser.  If you used www.example.com as your main URL, type example.com in the address bar and hit enter.  You should see the URL change to www.example.com.  If you used example.com as the main URL, typing www.example.com and pressing enter should change the URL to example.org.  If you use a tool such as Fiddler or Firebug, you’ll see the 301 Moved Permanently response, followed by a request for the main URL.

You have now successfully configured a canonical redirect.  Congrats!

Related Posts: Canonical Redirect with Apache 2

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>