BowlerHat is a Local SEO consulting & SEO
Audit
company that helps you win online

301 Redirects for SEO from Windows Server & IIS

sign showing different directions This article gives you a quick overview for making SEO friendly IIS 301 redirects from Windows server using the web.config file.

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.

1. Web.Config

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.

<location path="page-to-redirect.html">
<system.webServer>
<httpRedirect enabled="true" destination="http://www.destination.co.uk/new-page.html" httpResponseStatus="Permanent" />
</system.webServer>
</location>

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.

<system.webServer>
<httpRedirect enabled="true" destination="http://www.newdomain.com/" />
</system.webServer>

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.

<system.webServer>
<httpRedirect enabled="true"  exactDestination="true"  destination="http://www.newdomain.com/" />
</system.webServer>

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.

Example Web.Config

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/.

<configuration>
<location path="old-page-1.html">
<system.webServer>
<httpRedirect enabled="true" destination="http://www.newsite.co.uk/new-page-a/" httpResponseStatus="Permanent" />
</system.webServer>
</location>
<location path="old-page-2.html">
<system.webServer>
<httpRedirect enabled="true" destination="http://www.newsite.co.uk/new-page-b/" httpResponseStatus="Permanent" />
</system.webServer>
</location>
<system.webServer>
<httpRedirect enabled="true" exactDestination="true" destination="http://www.newsite.co.uk/" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>

Beyond Redirection

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! :)

Marcus Miller

I am an SEO Consultant based in Birmingham UK and with clients all over the world. I have been working in and around search for 15 years and currently focus on SEO Consulting, Website Consulting, Local SEO and Technical SEO Audits.

Comments (2)

  • comment_avatar

    Turgut Sezer

    |

    hello, firstly sorry for my bad English.
    i need help about something, please if you know, can you teach me, how can i redirect all of “*.html” files to only “/”
    here example:
    DOMAINNAMEURL/post-1.html to post-1/
    DOMAINNAMEURL/post-2.html to post-2/
    DOMAINNAMEURL/post-3.html to post-3/
    i did not write my domain url because of mark spam comments
    DOMAINNAMEURL = vvvvvv-dot-gizlitarif-dot-kom

    Reply

    • comment_avatar

      Marcus Miller

      |

      Hey Turgut, I am a bit rusty with IIS redirects but that should be simple enough and you just need to set the location path to a wildcard like *.html – so… location path=”*.html” and you should be good to go.

      Reply

Leave a comment