I’ve talked about that in the past, but it seems this is a constant issue especially if you’re migrating from one content management system to another. In my case I moved away from my custom coded cms to WordPress because I found out that wordpress is offering quite a bit of built in tools (and some excellent plugins) that are extremely useful for good website productivity. In such situation (even if you’re moving to a different CMS) you will need to take good care of your existing file/content(uploads)/pages structure so that it can be easily re-indexed by the search engines. If this is not done carefully you can trash all your Search Engine keyword Positions down the drain.

In order to prevent any damages you will ultimately have to configure the Search Engine Friendly URLs to look in the exact same way as on the old website. Unfortunately in most cases this is not possible and we have to implement some form of Search Engine Friendly redirects — the so called 301 permanent redirects. This can easily be done if you have a small website, but might be problematic with larger ones.

The main problem you will stumble upon is that most new content management systems use .htaccess url rewriting which can complicate your life a bit. If your CMS is using it, then it is highly recommended that you get a Plugin to manage all redirects. In my case I’m using the WordPress plugin “Redirection” which enables me to add manually URLs, specify the redirection code (301, 302 and etc) and the new url. Using this type of plugins you can quickly import large number of files and ultimately all of them, but in most cases we miss some and that’s not good.

If we are not able to find all URLs and redirect them to the appropriate new page, we might hurt our Search engine rankings because all (yes all) search engines are currently tracking their users on time spent browsing the results. If you don’t believe me then just check out the source generated from Google or Yahoo and you will notice that they have internal “onClick” event to trigger some sort of monitoring system. As a fact, I’ve noticed that Google quickly alters its search engine index positions to URLs which return 404 code. Using some simple logic we can explain why they do that — to return only high quality listings instead of outdated (that’s what 404 means — not existing any more). This is our primary motive to carefully investigate all URLs and redirect them properly to the new website/cms.

If you’re not able to find any Plugin for your CMS or you are using your own custom made one, then you can use the following PHP script that I wrote a while back. It uses CSV table to redirect pages as follows:

301.csv file contents (note that there can be ulimited number of lines to this file, you just add whatever you need)

URL|REDIRECT
/news/old-url-1.html|/new-url.html
/other-old-url|/new-url2
/category/somepage-old.html|/

PHP 5 Code note that you must put that code in the header — the first lines of your php script — in order to have the Headers work properly. Otherwise you’re going to see “headers are already sent” warning/error from php.

        // Process 301 Redirects
        $redirects_file="301.csv";
        if(file_exists($redirects_file)){
            $handle = fopen($redirects_file, "r");
            $key = fgetcsv($handle, 1000, "|");
            while (($item = fgetcsv($handle, 1000, "|")) !== FALSE) {
                if($item[0]==$url){
                    header("HTTP/1.1 301 Moved Permanently");
                    header("Location: http://www.my-domain-name-here.com".$item[1]);
                    die();
                }
            }
        }

Fortunately for us, we have Google Webmaster Tools to show us where we went wrong. In my situations, I’ve discarded some of my old URLs which I found to be off-topic and I didn’t copy into the new website. What I did wrong is that I didn’t 301 them to the homepage — which is the right thing to do since you’re not going to lose any PR or backlinks from those pages. Check out what Google showed me in the Crawl stats on page errors:

Google Webmaster Tools showing some 404 ERRORs

Google Webmaster Tools showing some 404 ERRORs

What I suggest you do is that you go to the Webmaster Tools (approximately a week after you’ve completed the new CMS transfer) and check if you have some warnings or errors. I’m not exactly sure what Google’s policy on 404 pages is, but I’m assuming that they should give around a Month for you to Fix those errors — we’re all humans and we’re prone to do mistakes from time to time. If you do get some warning its good idea to fix them as soon as possible, so that you won’t lose the benefits those 404 pages had.

If you don’t have Google Webmaster account (which you should have one) then you can use the CPanel built in ERROR Log or even the AWstats 404 errors page. The only thing you should be careful of is that some bad bots and even some search engines crawl for NON-Existing content to verify your Error handling or even to search for security exploits on your website. You must be able to note which 404s are real and which are “manufactured” as those two programs get their stats from the RAW apache logs as Google Webmaster Tools get only the REAL urls which have backlinks and values.

BTW: as I said I’ve listed the WordPress Redirection plugin as my preference, but if you know some other plugin for Joomla, Drupal or other CMS then please post comment to this post!