If you are looking to make sure your site is as optimized for search as it can be, you have probably been told to do a redirect from your non-www domain to your www domain. This is not too difficult when you are hosted on Linux, but can be a little more tricky when you are on a Windows based hosting plan. Even more troubling if you are on shared Windows hosting. Here is a quick how to if you are leasing a Windows based server and have IIS access.
The method below will do the redirect without any additional software such as ISAPI Rewrite. I am not saying you shouldn’t purchase and install ISAPI Rewrite. I am just looking to provide an install free method.
I will use example.com as the domain name in the how to. Obviously this is where your site name needs to go. This will allow requests for http://example.com/mydirectory/detail.cfm?myid=555 to be 301 redirected to http://www.example.com/mydirectory/detail.cfm?myid=555.
- Log into your server
- Open IIS Manager
- Right-click the site you wish to modify and choose Properties
- In the Web Site tab, under the Web site identification section, click the ‘Advanced button’.
- Under Multiple identities for this Web site, make sure there is a Host Header value for the ‘www’ version of your domain name (www.example.com). Make sure there is no value for the ‘non-www’version of your domain name (example.com)
- Click OK and go back to the IIS Manager
- Create a new web site. In the Web Site Creation Wizard enter the following values:
- Description: Enter a description such as ‘example.com Redirects’ (remember to always comment your code too)
- IP Address: The IP assigned to the domain in its DNS record
- Tcp Port: 80
- Host Header: Enter the ‘non-www’ version of your domain name (example.com).
- Home Directory Path: Can be the same as your current site for now.
- Permissions: Can be the same as your current site.
- Right-click the new web site and choose Properties
- On the Home Directory tab, under ‘The content for this resource should come from’, choose A redirection to a URL.
- In the Redirect to field, enter http://www.example.com$S$Q where example.com is your domain name
- Under The client will be sent to, check the box next to The exact URL entered above. Also check ‘A permanent redirection for this resource’
That should do it. Don’t forget to test, test and then test again.