Skip to content
 

Evolving PlanetMike.com: Chapter 4 – Copying the Database and Redirecting

Ok, I’ve moved a whole bunch of posts from PlanetMike.com over to my personal site, MichaelClark.name. While tedious, it was a pretty straightforward process.

  1. Install WordPress on your new domain. Make sure it is the same version as the one on the old domain!
  2. Copy the active theme to the new site’s theme directory. This should be under wp-content/themes/.
  3. Copy all of your plugins to the new site’s plugins directory. This should be under wp-content/plugins/.
  4. Copy the WordPress database to a new database. Ideally, make a backup of the old site’s database, and then import it into a new database. At this point you have two WordPress database set up with 100% duplicated content, users, passwords.
  5. Use a mysql editor to edit the “siteurl” and “home” values in the wp_options table. I used Navicat, but you could use any mysql database editor like PHPMyAdmin or the command line.
  6. Then simply edit the wp-config.php file on the new site so it can read the new database.

Tada! You now have a complete copy of your old WordPress blog on a new domain.

I took this opportunity on the new site to change my permalink structure. I removed the dates from my post’s URLs.

Important! If you have any photos, style sheets, images, included files, or other content referenced from the old site, those links won’t work on the new site until you copy or move that content over. And since I was splitting out my personal information, I had a lot of other info to move around.

My goal was to have my photos, family stuff, jokes, etc… all on my personal site. So I moved those directories to their new location. But for now I don’t want those pages to break if someone visits that URL. So I created a link from the new site to the old site. For example:

ln -s photos ../www.planetmike.com/photos

I did this for a bunch of directories. To the end user, you can’t tell that anything has changed. But I do have the same content on two domains now, which could mean a penalty at some point from search engines. The reason I had a bunch of directories is that PlanetMike.com has been around since 1997, the days before there were content management systems available.

Now another tedious step: removing duplicate content from the blogs. On the new site I went through and removed a bunch of posts and categories that will not be used there. On the old site I didn’t have to do anything with those posts, since they aren’t changing.

And the final tedious step: On the old site, look at each post in the categories for the new site. A very few of these posts could be deleted entirely, from both blogs. But most needed to be redirected to the new site. I created a list of URLs from the old site that were to be redirected to the new site. I did this by category, just to keep this in manageable chunks. A few posts I reclassified into other categories. Then in my .htaccess for the blog, I added the RewriteRule, one for each URL:

RewriteRule 2005/09/15/virginia-tech-photographs/? http://www.michaelclark.name/virginia-tech-photographs [R=301,L]

This rule says if the requested url contains 2005/09/15/virginia-tech-photographs (with an optional slash at the end), that page has been permanently redirected to http://www.michaelclark.name/virginia-tech-photographs. As I added each category’s URLs to the .htaccess file, I deleted the post from the old blog. Anyone that requests the old URL would transparently be bounced to the new site. That might be confusing to people who visit the site during the transition.

I ended up with over 270 lines in the .htaccess file. I could have used some regex (regular expression) magic, but I liked actually touching each URL. By doing each URL one at a time, I was able to basically audit the entire site.

I finished this step a week ago, and have been watching my server logs and my Google webmaster account for problems. One problem I’m seeing now is that some of my category and monthly archives had multiple pages, but since I’ve pruned the number of posts down, the highest numbered pages don’t exist any longer. I’ll be leaving that as a 404 error so that the search engines will remove that page from their indices.