Redirecting www.* subdomain to the root domain in IIS 7

Having your site available on www.yourdomain.com and yourdomain.com isn’t good for your SEO as it splits the domain authority. You can use the Google Webmaster Tools to specify which domain Google should use, but you should also redirect on the site itself. You can do this in your web.config directly, but IIS has a module to do it for you. Redirecting from a sub-domain in IIS 7 is really easy using the URL Rewrite feature.

First select the URL Rewrite module for your domain:

Click Add Rule in the top right panel and select Canonical domain name.

Add the your domain name without the www.

You will see your rule has been created…

Now we need to make the redirect send the 301 HTTP header, which makes it a permanent redirect, so select your rule and hit “Edit…” in the right side bar, scroll to the bottom and change the Redirect type to Permanent (301).

This will make your web.config file something like this…

top