10 Apr 301 Redirects for SEO from Windows Server & IIS
There are other ways to redirect from Windows Server and Dot Net (.Net) but here we are just looking at the the path of least resistance for making simple 301 redirects for SEO purposes.
A quick word of note being the bulk of my rewriting experience is with Mod Rewrite under Apache and .htaccess so this had to be easy for myself and subsequently, this is a guide for Windows or non Windows folk alike. If anyone has any additional resources or suggestions for this article please drop a comment below and I will update the main article.
Windows 301 Redirection Basics
When redirecting for SEO purposes we are hoping to pour the value of a page / site into another page / site. With this in mind, we should always try to point an old page at the most relevant replacement rather than just doing some kind of catch all hack redirecting all pages to the homepage. Equally, with an eye of avoiding SEO penalties, it makes sense to do things in as non spammy way as possible and sitewide 301 redirects to the homepage are simply not a good idea.
What this means it that your redirection file will most likely have a bunch of specific redirects for individual pages, some whole directories and then some wild card or catch all redirects to mop up any spillage.
Your redirections will be made from a web.config file in the site root. So, first job is to create a web.config (if it does not already exist). You can use FTP or possibly your hosting control panel to get access to your web root.
There are a few things to note about the syntax used for making 301 redirects from IIS on window servers in a web.config file. Firstly, everthing is wrapped up in <configuration></configuration> tags and secondly, the value set in the httpResponseStatus should be ‘Permanent’ to issue the 301 code we are looking for.
2. Basic Redirection
This is your bog standard 301 redirect in the web.config file that you will use for redirecting the bulk of your pages. This takes page A and simply redirects to page B. This is handled instantly for a human visitor or search engine and will pass most of any value from the original page through to the new site.
<httpRedirect enabled="true" destination="http://www.destination.co.uk/new-page.html" httpResponseStatus="Permanent" />
3. Changing URL
This simple redirect points people at a new URL so if you have changed domain BUT the page names are all exactly the same, this one simple rule is all that is required.
<httpRedirect enabled="true" destination="http://www.newdomain.com/" />
4. Catch All 301 Redirection
You may have cause to redirect all pages or all pages that don’t have a specific rule to another page and this will do the job. This is essentially the same rule as above with the exactDestination=”true” rule added to the httpRedirect.
<httpRedirect enabled="true" exactDestination="true" destination="http://www.newdomain.com/" />
5. Wildcard 301 Redirect
IIS web.config redirects also support wildcards to redirect a given type of files to another location and this works much like a basic DOS wildcard character with *.* being the catch all redirect. You will likely want to redirect one type of file, say HTML files for instance so your wildcard would be something more like *.html as below.
If one of your redirect rules is triggered, the subsequent rules are ignored. So, a typical approach would be to add some specific rules (2) then finally a catch all to catch any stragglers.
The set up below gives you a complete example and a template that works this way with specific redirections and a catch all redirection. In the below example we do two specific redirections from old-page-1.html & old-page-2.html and then finish up with a catch all 301 redirect to send anything left over to http://www.newsite.co.uk/.
<httpRedirect enabled="true" destination="http://www.newsite.co.uk/new-page-a/" httpResponseStatus="Permanent" />
<httpRedirect enabled="true" destination="http://www.newsite.co.uk/new-page-b/" httpResponseStatus="Permanent" />
<httpRedirect enabled="true" exactDestination="true" destination="http://www.newsite.co.uk/" httpResponseStatus="Permanent" />
There are a few important points to keep in mind here. The first being that the redirection should stay in place, you can’t just whack this up and then kill the redirection a week later – this is even more true if you are doing redirections to a new domain. Secondly, if you have links to some high value pages, and they are moving to another site, the redirection is great, but if you can make changes to the those links to point to the new property then you should do that.
Redirect your questions to the comments
If you have any questions then drop a comment below. If you are feeling kind, please share this page with the links below and you can always catch me on Twitter. Now, redirect yourself back to the job you are supposed to be doing! 🙂