Safe Redirects for SEO

9 Jun

We all know that Search Engines hate change. Whenever we decide to do a total restructural change of any site we run the risk of pissing off search engines. And when we piss off search engines, we start to drop down the rankings.

Why? Because when we change the structure of a site (i.e. add or remove pages from the existing structure) Google doesn’t know where to find the new pages until we tell them. Now we could just use a meta refresh but search engines have to come to view these as spamming tactics and you run the risk of being penalised. So instead you need to permanently redirect your bots (and human visitors!) to the new page, straight from the old page and create a safe association in the consciousness of Google between those two pages.

You can set up server side methods to allow for 301 redirects on both Apache and IIS but sometimes you’re on a shared hosting account that doesn’t allow access to these methods. So what do you do? You script the changes manually. You can use PHP, or ASP or .NET to script a 301 page very easily.

PHP

ASP

VB.NET

So you simply paste this code into your old pages, remove the content that used to be in there and adjust the target URI to point to the new page – job done. Google now associates the new page with the old and you should keep your hard-fought for PR and rankings.

What about when you have a *lot* of pages that are being redirected? For example, an old version of the Group site I work on changed from trad ASP to .NET and hence all our pages needed rebuilding and the site structure changed a lot. The old version of the site ran off the index.asp page with pages being called in depending on the values in the query string e.g. …/index.asp called in the home page obviously but …index.asp?TYPE=02 called in the Mortgage pages and …index.asp?TYPE=02&aid=5 called in the first time mortgages page in the mortgage section. So I had to allow for all these pages which were indexed in search engines and working nicely. I did this like so:

I saved that page as index.asp (which didn’t conflict with my new index.aspx page) and then every time a search engine sent a visitor to an old page the case statements sorted out where to send the visitor in the new structure. Job done!

10 Responses to “Safe Redirects for SEO”

  1. Mathias Bynens June 9, 2005 at 15:44 #

    Or via .htaccess and mod_alias:

    Redirect 301 /oldfolder http://domain.ext/newfolder
    Redirect 301 /oldfile.ext http://domain.ext/newfile.ext

  2. Tom June 9, 2005 at 22:50 #

    .htaccess is my fav.

    btw Kevin why dont you use mod_rewrite for your posts and stuff?

  3. Kev June 10, 2005 at 07:00 #

    Tom: Cos I can’t get it to work ;o)

    This is one of the reasons I wrote this – those of us who are regex or htaccess challenged (i.e. a bit thick ;o) ) need a way to do things like this.

  4. Prabhath Sirisena June 10, 2005 at 07:05 #

    Com’on Kev, htaccess can’t be difficult for a seasoned designer like you :o) But this is some good stuff.

    BTW, doesn’t WP create the htaccess for the permalinks on the blog?

  5. Kev June 10, 2005 at 08:10 #

    Well, I wouldn’t call myself an htaccess expert but I’m OK with it ;o) what I meant by ‘challenged’ was having it as an option at all – a lot of hosts (especially on shared hosting accts) aren’t allowed to mess with their htaccess file – or they’re on a non-Apache server.

  6. Toxie June 10, 2005 at 14:35 #

    Don’t let Jason see the php way he may have a fit….on the other hand ;¬)

  7. Kev June 10, 2005 at 14:46 #

    Hey there Mr O’Grady! I wouldn’t dare show Jason – he shouted at me when I asked for help about detecting referring URI’s!

  8. Matt Robin June 10, 2005 at 20:27 #

    I think I would have looked to do this directly in the htaccess file (as I’ve done before).
    But I like the php approach (nice!)….
    I don’t get much call for redirecting though – but that doesn’t mean it’s not useful to know how to do it a different way.

  9. Toxie June 11, 2005 at 13:39 #

    Long time no see Mr Leitch.
    Ah yes Jasons favourite R word, I think you only do it to get someone elses BP up ;¬)

    I ignored his advice anyway and went with the php one for stuff I didn’t know how to do with .htaccess

  10. Scott January 5, 2006 at 10:40 #

    Good tips! The .htaccess one is nice as it is very clean all redirects are located in one place.

Comments are closed.