This guide shows you how to redirect your site from www to non-www on server level with IIS 7.5.
www is actually a subdomain for your main domain (domain.com), which means both www.domain.com and domain.com will serve the same content, if you don’t redirect either www.domain.com to domain.com or the opposite way around. It’s highly recommended to do so, to prevent duplicate content. Which you prefer is entirely up to you, as it doesn’t matter in search engine rankings, as long as you choose one.
Fire up Internet Information Services (IIS) Manager by hitting CTRL+R and type inetmgr [enter]
Choose your site in the left menu and open up “Url Rewrite”
Click “Add rule(s)…”
Choose “Blank rule” under Inbound rules and click [ok]
Give your rule a name, eg.: Redirect to non-www
Request URL: Match the Pattern
Pattern: (.*)
Open up the “Conditions” tab
Condition input: {HTTP_HOST}
Check if input string: Does Not Match the Pattern
Pattern: ^domain\.com$
Scroll down to the “Action” tab
Action type: Redirect
Redirect URL: http://domain.com/{R:1}
Make sure Redirect type is set to “Permanent (301)”
Done!
Another option, is to add the rule in your web.config manually:
[xml]
<rewrite>
<rules>
<rule name="Redirect to non-www" stopProcessing="true">
<match url="(.*)" negate="false"></match>
<action type="Redirect" url="http://domain.com/{R:1}"></action>
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.com$" negate="true"></add>
</conditions>
</rule>
</rules>
</rewrite>
[/xml]