Change website URL without breaking links or images? WP 3.3

There is a helpful codex article about moving WordPress: http://codex.wordpress.org/Moving_WordPress.

Basically, you need to find/replace the DB for instances of your old domain, and swap them with your new domain.

One additional trick I’ve learned when moving WordPress between environments: since WordPress stores the domain in several places as serialized data in the DB, you need to be careful when doing a find/replace on the domain name. You can use a special script like this one to do the find/replace for you, or you can do something much simpler: use domains that are the same length for dev, staging and production.

For example, your domain scheme might look like:

  • dev.domain.com
  • stg.domain.com
  • www.domain.com

This way, you CAN do a straight find/replace with a text editor, and you don’t have to worry about breaking any serialized data.

One more thing: in your theme, always reference files using relative paths, or helper functions like get_bloginfo(‘template_url’). This way, you never need to modify URLs between environments.

Leave a Comment