If you want to manage the canonical domain of your website here’s a simple way to do it.
1. Install the URL Rewrite module
The Url Rewrite module is from Microsoft and may, or may not, be pre-installed with IIS. If it’s not you can get it at the iis.net site
2. Add the rewrite rule
Open IIS, select your website in the Sites tree and open the URL Rewrite module in the IIS section.
In the Actions list on the right side of the IIS dialog select “Add Rule(s)”.
In the Add Rule(s) dialog select “Canonical domain name” under the “Search Engine Optimization (SEO)” block.
3. Remove WWW
In the “Add a rule to redirect to a Canonical domain name” dialog select your primary host name. This domain name will be a “naked” domain without the “www”.
Click OK and you’re done.
Well, you’re done if you want to remove of the “www” part of the domain.
4. Force WWW
If you want to force the “www” part of the domain expand the rule in the URL Rewrite list, select the rule and click “Edit…” under “Inbound Rules” in the Action menu at the right side of the screen.
This brings up the “Edit Inbound Rule” dialog. Under “Requested URL” change “Does not match pattern” to “Matches the Pattern”. At the bottom of the dialog change the “Redirect URL” to include the “WWW”.
Whichever option you choose, this is the simplest way to get it down. The Inbound Rule will be updated in your web.config and if you so desire, you can edit it directly there.