Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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 domain.com to www.example.com?

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

share|improve this question

migrated from stackoverflow.com Sep 7 '11 at 14:47

This question came from our site for professional and enthusiast programmers.

    
why vote to close? –  LostLord Sep 6 '11 at 22:37

2 Answers 2

up vote 4 down vote accepted

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 domain.com from your original site. Add a new site bound to domain.com, and make this redirect to www.domain.com

share|improve this answer
    
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? –  LostLord Sep 6 '11 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 soscharge.com and www.soscharge.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 soscharge.com should suffice in this case.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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