Moving a blog isn’t something that should be taken lightly. Don’t do as I did.
While waiting for a new build from the development team (of one), I decided to poke around a bit. I’ve been meaning to move the blog off to its own domain for years. Why today? Don’t know.
A quick whois shows that fibermusings daht anything is wide open. I quickly registered it and added it to my hosting service account. Within 5 minutes, the website is up. I started to research how much work it is to move the blog from the old domain to the new. The answer, not much. Since it’s all on the same hosting account, I don’t need to do a new installation. I just needed to move it from one directory to another.
Huh. Really? That easy? Let’s try it…
Yeah, that’s all the thought I put into it. Not much. No planning. No thinking through the possible issues.
Things start to fall apart after that.
WordPress encodes full URL to all image links. Yup. All posts with pictures have to be changed. Manually. A quick Google search shows that I can do it via a SQL command to the MySQL database. Here’s the nail biter. You’re changing a live database. Yeah, I can do the whole backup and restore business. But I usually have DBAs who do this sort of stuff for me. I decide to go for broke. I’ve done everything up to now half assed, I might as well continue.
Here’s the appropriate MySQL command:
SET post_content = replace(post_content, ‘old_url‘, ‘new_url‘)
For example, if your WordPress database table prefix is wp_, then in place of <wp_prefix_posts> you would enter wp_posts. I did try it out on a single image heavy post first to make sure it worked before applying the script to the entire table. (Add ‘WHERE post_id = <some_id>‘ to the end.)
You need to apply this to the <wp_prefix_postmeta> table as well. A little more care is required here since this contains file system path instead of just URI.
Then there was the matter of redirecting the old blog location to the new. More Googling shows a nifty trick with the .htaccess file with the following line:
Redirect permanent /<old_blog_directory_location> <new_URL>
Place the .htaccess file in the root directory of your website. And voila! Everyone going to the blog in the old location will be automagically redirected to the new location.
Of course, this only resolves the issue of when someone actually visits your website. Anyone reading the blog using an RSS feed is hosed. The feed is broken and I don’t know how to fix it. They have to re-subscribe. But then, it’s the age old question. “If a tree falls in a forest and no one is around to hear it, does it make a sound?” The equivalent here is, if everyone is using RSS Feeds (Bloglines, Google Reader, what have you) to be notified of new posts, and you’ve stopped publishing feeds at the old location, how will they ever know that you’ve moved?
The correct answer would have been to make a post announcing the up-coming move. Wait until the aggregators have received the feed, then make the actual move.
Yeah, that would have been smart. But I didn’t think of it until it was too late. Now it’s broken. There’s a new feed and no way to push that out there. Idiot.
Then, I come to find out that by moving it the way I did, I broke the smart upgrade system that my service provider provides. It’s their system for one-click upgrades for installed software packages. I have no clue what I’m going to do about that. I’ve sent off an “I’m an idiot. Please help me.” message to their support. We’ll see what they have to say.
Moral of the story? Don’t do as I do. Do as I say. Don’t do things half assed. Think it through first. I know better, but still didn’t follow my own advice. It may be a case of the cobbler’s children have no shoes.
For now, I’m okay as long as WordPress doesn’t come out with an urgent patch.
Update 1: The .htaccess hack appears to do the trick. The old RSS feed pings bounced off of the .htaccess file and onto the new feed. So the old feeds will continue to be updated. Hooray! This is confirmed with both Bloglines and Google Reader.
Update 2: My hosting service replied with, “If you’ve gotten this far with your blog move successfully, you have the requisite skills to upgrade WordPress manually.” And followed it up with atta-girl.
I guess I got lucky.