Redirecting non-www domain to www domainposted on 2 September 2008 | posted in IIS
If you want people to be redirected to http://www.yourdomain.com/ when they enter http://yourdomain.com, here's how to do it in IIS:-
1. Go to IIS on the server and right click / select properties on the domain you want to do this for
2. On the Web Site tab (the one already selected), clicked Advanced next to IP Address
3. Under "Multiple Identities for this website", if there's a record there without "www" (e.g. yourdomain.com), select it and remove it.
4. Click OK, Apply (to close these windows)
5. Now add a new website to IIS by right-clicking on "Web Sites" > New > Website
6. Call the description something meaningful like "yourdomain.com redirect". Click Next.
7. In the "Host header for this Web site", enter your domain name WITHOUT www - e.g. yourdomain.com
8. Select a path for the website. It's best to point this domain to an empty folder (just make one up) somewhere on your server (as this domain isn't going to be used to host anything).
9. With this new website added, right click on it in IIS and select Properties, and select Home Directory
10. Now click on the radio button next to "A redirection to a URL", and enter this in the textfield below :-
http://www.yourdomain.com$S$Q (replace "yourdomain" with your actual domain name)
11. Now tick the box next to "The exact URL entered above", and also tick the box next to "A permanent redirection for this resource". Click OK and Apply
Done! Now whenever anyone enters http://yourdomain.com, they are redirected to http://www.yourdomain.com. Note that this applies to ANY URL - that's the power of this tip - so you don't have to keep redirecting millions of individual URLs. It also is SEO friendly since it's a server-side redirect and search engines have no problem with this.