How I Migrated this WordPress Blog


I first set this blog up as a subdirectory of one of my other domains. Then I decided it was a better plan to give it a home of its own. I was (not for the first time) overcomplicating.

Now, the original database only had a few posts, but there were a few links out there, and I didn’t want to leave them hanging in mid-air.

Setting up the destination …

… was easy. A new domain, a new database, and uploaded the WordPress and theme files. Then WordPress’ Export function took my database across.

(I’d forgotten I could copy my links across using the OPML format (under “BlogRoll” in the Import tool – but I didn’t have too many anyway.)

So my new site was up-and-running. But I still had some traffic on the old version that I wanted to redirect to the new home.

Messing with .htaccess

This took a while to figure out. The .htaccess file is part of the Apache webserver (so it may not be there in a Microsoft implementation). It is very powerful, but with great power …

Then I found I had to work in the directory one level above the actual blog folder – so for a blog in olddomain.co.uk/critical-focus, I had to change the .htaccess file in the root folder (olddomain.co.uk/httpdocs in this case). I always put my blogs at least one level below the root directory.
The .htaccess file is a special-purpose file that Apache looks for. It can’t be opened directly through a web browser – it can only be uploaded through ftp, or the file editor when you’re logged on to the web server (through Plesk or CPanel). And it can get very complicated.

But I only needed a one-liner in this file :

Redirect 301 /critical-focus https://critical-focus.net/blog

(this is a “301” – permanent redirect – that points all requests from the critical-focus directory to the new blog domain)

And all my old links end up here …

No, seriously, this is the really cool bit. All the tag and category links join up. And even my posts – which have a slightly different permalink structure.

So – when I get around to it – I can unhook the old database structure and WordPress files, as long as I leave the folder and .htaccess file until all the search engines have got used to the idea.