Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

notice how has no subdomain? If we want to do the same thing with our website -> redirect all traffic from www.***.com to ***.com, how can we do this?

At first, I thought it might be possible using IIS7's Url Rewrite free extension? And if so, can all requests be 301 redirected?

share|improve this question
Any reason why a CNAME wouldn't work? – gravyface Nov 15 '10 at 1:57
CName's do not handle HTTP Status. it's just for resolving ip's. Totally seperate issue. More info: – Pure.Krome Nov 30 '10 at 0:32
up vote 1 down vote accepted

Absolutally. Because IIS7 does not use .htaccess compatible rules though, it's not as simple as doing it in Apache or ISAP Rewrite.

This page here has all the details you need (due to IIS7's graphical nature, it's difficult to reproduce here). If you're into editing your web.config file manually, the correct procedure is:

<rule name="Canonical Host Name" stopProcessing="true">  
    <match url="(.*)" />  
        <add input="{HTTP_HOST}" negate="true" pattern="^$" />
        <add input="{HTTP_HOST}" negate="true" pattern="$" /> 
    <action type="Redirect" url="{R:1}" redirectType="Permanent" />  
share|improve this answer
Awesome :) And i always use the config file (so I can easily migrate the site around) instead of using the UI. So, this looks like the Url Rewrite extension queries each incoming request. It then checks two regex patterns. First is for any subdomins? second is for the www subdomain. If found, does a 301 and stops. Yeah? – Pure.Krome Nov 14 '10 at 23:37
@Pure - yes. If you're not interested in subdomains, then get rid of the first one and just use the 2nd input rule. (in fact that first rule overrides the 2nd rule anyway, as the 2nd rule is a subset of the first) – Mark Henderson Nov 15 '10 at 0:00
two quick questions. 1) What's the configuration section this goes in? <?xml..?><configuration> ... <rewrite><rules><rule .../></rules></rewrite> .... </configuration> .. and 2) if this section is in the web.config ... and IIS ReWriter is not installed/added to the server .. this section is ignored BUT the site still runs (ie. this ignored section won't cause a site to crash .. because it's ignored). – Pure.Krome Nov 30 '10 at 4:16
@Pure - unfortunately I'm not anywhere I can check the web.config file at the moment, but I'm fairly sure if you put it in your web.config file and rewrite isn't installed you get Error 500's on your site, so be careful! – Mark Henderson Nov 30 '10 at 4:20

Your Answer


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.