Friday, February 05, 2010

Relocation accomplished

G4ILO's Blog is now at its new home and I'm hoping that nothing got left behind in the move!

The actual change from FTP hosting to Blogger hosting was fairly easy. It was just a matter of selecting the "custom domain" option from the publishing options, then clicking the Advanced button and putting in the name I wanted:

I also had to specify something called a "Missing Files Redirect" which tells the Blogger server where to look for any files used in the blog that it doesn't have. This is important because although the text content is now served up by Blogger (and presumably any images included in new postings will be hosted there) all the images in my existing postings remain where I uploaded them, on the old server. And I certainly did not want to go through over 300 postings editing all the image locations to provide their full path!

Next I had to go to my web host and create a CNAME record for the new domain which pointed to This basically tells the world via the Domain Name Service (DNS) that is hosted on Google's server. I then had to wait while this information propagated around the Internet, so I went and helped Olga get the shopping.

That was the easy part. The difficult bit - the part I was concerned about - was ensuring that all references to my blog at its old location would automatically redirect to the new one. Google was promising to build a migration tool that would take care of all this, but I was afraid that it would only take care of the situation where people only had a blog on their server. My blog was cohabiting with my G4ILO's Shack website so I wanted only links to the blog pages to be redirected.

Blogger techs told me "you can write an .htaccess file that can do this" but they seemed to have rather more faith in my ability to do this than I had. The .htaccess file is a configuration file used by Apache web servers that allow them to do more than simply serve the page "blah.html" when someone's browser requests that exact page. None of the .html pages at G4ILO's Shack exist as real files at all. They are all generated on the fly from a MySQL database by a content management system which knows what text is required thanks to an .htaccess file that the CMS authors thankfully provided. And I didn't want to break that.

The .htaccess file uses something called "regular expressions" to match against the filenames that are requested. They caused a perplexed expression to appear on my face because I don't have the kind of mind that is good at puzzles and I just couldn't figure out how to use them. So I did what I normally do when I hit a technical problem: Google to see if someone cleverer than me had had the same problem and managed to solve it.

I found several examples where people had transferred their blog from, or even from just where the blog was the only thing on the server. But eventually I managed to find some examples which, with a bit of trial and error testing, seems to do the job of redirecting all requests for blog files to the new server. For the benefit of those following in my footsteps, the lines I had to insert in my .htaccess file are:

RedirectMatch permanent ^/blog.html$
RedirectMatch permanent ^/rss.xml$
RedirectMatch permanent ^/atom.xml$
RedirectMatch permanent ^/20([0-9][0-9])_([0-9][0-9])_([0-9][0-9])_archive.html$$1_$2_$3_archive.html
RedirectMatch permanent ^/20([0-9][0-9])/(.*)$$1/$2
RedirectMatch permanent ^/labels/(.*).html$$1

These take care of, respectively, my old blog main page (blog.html), the RSS and Atom feeds, the archives, the individual posts, and the labels.

The thing that caused the most head scratching in the end was the bit of code that displays the last ten blog topics on the front page of G4ILO's Shack. This is generated from the RSS XML file produced by Blogger but for some reason it worked with the copy that was stored on my server but not with the one obtained direct from Blogger even though they looked practically identical. But after more trial and error that issue was also resolved at around midnight last night.

I'm crossing my fingers, but I think it all works. I have deleted all the blog files off the old server now, apart from the uploaded images of course and a few other files used by the template. Please let me know if you notice anything that seems wrong.

My blog address is now and you should update it if you are not receiving updates. But because of the redirection, hopefully you won't need to. Now I'm going for a lie down. Somebody please pass me an ice pack!
Post a Comment