At DiscountASP.NET, we set up your web site to handle both and  By having both hostnames (with or without www) bring up your web site, you don’t risk losing potential visitors.  This setup, however, is not favored by search engines.  According to many Search Engine Optimization experts, search engine bots will penalize you for duplicate content if you have multiple hostnames pointing to the same content.  SEO experts recommend the server returns a 301 permanent redirect to avoid getting penalized on your search engine ranking.

In this post, I am going to discuss a very simple technique for configuring your site to redirect to using the URLRewrite module.  Note that this feature is only supported on the IIS 7.x platform.

1. Download and install IIS Manager.  See our Knowledge Base for more information.
2. Connect to your site using the instructions listed in the above KB article.
3. Navigate to the URLRewrite section.
4. Click on “Add Rules” in the Action pane.
5. Configure the rules as below.  I am using for this example; make sure you replace with your own domain name.

6. Click “Apply” in the Actions pane.
7. IIS should now issue a 301 redirect for all requests going to and redirect them to
8. Note that the URLRewrite rule is written to your web site’s web.config file.  If you update your site in the future, your web.config file may be overwritten.  I recommend that you add the URLRewrite rule to your local development web.config file.

Here’s the result of an HTTP header check to show that the rule is working properly:

Server Response:
HTTP Status Code: HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Server: Microsoft-IIS/7.0
X-Powered-By: ASP.NET
Date: Tue, 09 Feb 2010 09:05:42 GMT
Connection: close
Content-Length: 150
Redirect Target:

Frank Cheung


1 Response » to “How to use IIS7 URLRewrite Module to Enhance Search Engine Optimization”

  1. Anuj Rathi says:

    Hi Frank,
    Really very good article. I just want to confirm one thing.
    Some developers suggest to set “301 redirect” in global.asax beginRequest event.
    Can you please let me know which one is better & why?

Leave a Reply

iBlog by PageLines