Thursday, 15 July 2010

Directing all visits to the www subdomain using IIS7

Your SEO champion will no doubt be banging his fists on his desk if you've built a site that allows users to view the same content on as well as

What he or she will be demanding is that one of them permanently redirects the user (with a 301 status) to the other. So how do you do this? Well, there might be several ways but this is the way I do it. For this example I'm going to be sending visitors from to

Remove the '' entry from the bindings of your website but keep the '' entry. Create a new website and call it ' redirect' or something similar. Add a binding to this for ''. This will then accept incoming visits to ''. Now click on the 'HTTP Redirect' icon:

and configure the site to redirect to '' with a Permanent(301) setting like below:

This will also honour any deep links to your site. For example if a user goes to they will be redirected to

UPDATE: on some machines you may not see the 'http redirect' icon. If this is the case go to the IIS section in 'Server Manager' and you'll probably see the role service isn't installed. You can install it easily from here.

No comments:

Post a Comment

Comments are moderated, so you'll have to wait a little bit before they appear!