Migrating wordpress sites to another host

When migrating wordpress sites, from one server/host to another… you might encounter some problems with 2 things:

  1.  Absolute vs Relative paths for e.g. images
  2. Serialized data.

This is how to fix both:

Absolute paths: can be fixed by my previous post here

Serialized Data: by modifying your absolute paths for URL’s of Image paths, your serialized data is no longer valid… I have found this script to be very usefull to fix the serialized data: BangHeadOnWall

How to use fix_serialization.php:

1. Download the script on the machine that has the db you need to fix
2. Change a couple of things in the script:

  • ‘db1′ to the actual database name
  • username
  • password
  • and maybe the table/column and index column (e.g. when using multisite)

3. type ‘php fix_serialization.php’ on the command line

The only real reason why I need to run this is because migrating the site can change the tite’s url length or absolute image paths.  For example ‘hard coded’ paths to images in some plugins:

The length of this string changes, and therefor the serialized string in the wp_options (or any other table using serialized string with url/data paths) is not longer valid.

The script goes through all that data and corrects the math in those couple of places automagically and you’re back online!

Leave a Reply

Your email address will not be published. Required fields are marked *