Migrating WordPress Problems

Migrating a WordPress blog & broken links

Wordpress Database Search & replace PluginI migrate WordPress blogs all the time. As a designer I make a dummy version of a clients website then after I have finished developing it, I will migrate it to my clients hosting server. Sometimes, I find that some of the image url’s look like this www.domain.com.au//wp-content/uploads/12/demo.png Can you tell me what’s wrong with this url?

That’s right! There are 2 trailing // when there should only be one. So how can we fix that?

Well in the old days I would make a database backup, open up all the database tables and look for the // and change it to a single /. It would take hours of work and I wasn’t sure I got all the double // Then I read a question posted on http://stackoverflow.com about how to fix this issue. The answer lead me to Search Replace DB v 2.1.0

Search Replace DB v 2.1.0 is a small application you can download free that lets you use the same function you get with notepad search and replace. So you search for the double // in your database and replace all the double // with single / It’s as easy as that.

Here’s what the developer says:

When you’re migrating WordPress (or any other platform using serialized PHP strings in the database) between domains, you must use a safe search and replace method that preserves the integrity of the serialized string lengths. A simple of a dump file for http://localhost to, for example, http://thenewdomain.com is problematic because the length of the string changes but the indexes for the serialized strings does not. Consequently settings are lost and widgets disappear. Not good.

This script can now also handle multiply nested serializations, which can happen in transient values in WP at times, and it can also handle multi-byte Unicode changes safely. This is important now that internationalised domain names are allowed.

It’s Not Only for WordPress

It’s worth mentioning that the code will work for any platform that stores PHP serialized arrays in a MySQL database. You can easily use this script on Drupal, Joomla and many other systems where you need to change items across a database without messing up your stored arrays.

Download Search & Replace Database plugin