How can I redirect example.com to www.example.com using DNS / IIS? I wish to do this for an asp.net web site to prevent duplicate contents (Bad for SEO).

I had 2 a record in dns (Windows Server 2008) for example.com and www.example.com.

Also in IIS I added example.com and www.example.com in edit bindings.

Which changes should I do in my IIS and DNS to redirect example.com to www.example.com?

Should I change the web.config file in my project?


2 Answers 2


The easiest way is to set up another site for the one you want to redirect in IIS. You then configure that site to be a redirection to the other one.

See here for details on setting up the redirect http://technet.microsoft.com/en-us/library/cc732969(WS.10).aspx

to install http redirection

  1. Click Start, click All Programs, Click Administrative Tools, Click Server Manager
  2. Expand Roles in the left bar, and click Web Server (IIS)
  3. In the main window, click Add Role Services
  4. In the Common HTTP Features, check HTTP Redirect and then click Install

both DNS entries need to point at your server, so that clients know how to get to either one. Remove the binding for example.com from your original site. Add a new site bound to example.com, and make this redirect to www.example.com

  • really thanks for answer / Http Redirection role not always installed in IIS 7.0 -> how can i install it ? / also which part of my iis or dns should i remove or change? Sep 6, 2011 at 22:36

In IIS, you can add a second host header in the Bindings section of a web application, so the same web application can answer example.com and www.example.com. This assumes that you don't care which URL is displayed in the browser address bar. A single entry in the DNS table for example.com should suffice in this case.

In this case HTTPS binding for both domain names can not be applied.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.