Redirect www requests to non-www requests using the rewrite module
Web.config example of using the rewrite module to permanently redirect (301) www requests
How to create a Rewrite Rule
In the <system.webServer> node, add the following rewrite rule.
<rewrite>
<rules>
<clear />
<rule name="www_rule" stopProcessing="true">
<match url="(.*)"/>
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="www." ignoreCase="true"/>
</conditions>
<action type="Redirect" url="http://yoursite.com{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
This rule looks for any request with "www." and permanently redirects to the equivalent non-www url. The {REQUEST_URI} variable will preserve the original request's path. If your site accepts query string parameters, change the appendQueryString to true.
For further information, see the following:
URL Rewrite Module Configuration Reference