Site Address Change

As you can see this blog is now being hosted from Blog.AdieNicholls.co.uk (or AdieNicholls.co.uk/blog).

In the past I have moved WordPress installs from development to live and also live migrations without any issues until I came to move this site.

I had carried out all the normal steps to moving a WP install;

  • Backup root folder
  • Backup database
  • Change site location in settings>general>WordPress Address (URL) and Site Address (URL)
  • Export database
  • Upload root folder
  • Import Database
  • Run the following SQL command to update any paths that are outstanding:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

With the above completed,  I navigate to the site and run though some checks to see if the move was 100% successful as normal, erm, well this time it seems that any wp-content/uploads links still had the old address!!! After re running the above SQL commands and that completing to result of 0 I checked and the images still had the old address… right, I am going to have to look at the instructions!!!

After a quick scan through it seems there are 2 really good tools for this job;

  • Database Search and Replace Script in PHP
    Search Replace DB version 3.1.0 allows you to carry out database wide search/replace actions that don’t damage PHP serialized strings or objects with a user friendly interface and experience.

To choose the easiest option first I installed Better Search Replace plugin for WordPress.  A quick, no hassle install and then jump to the Tools > Better Search Replace menu option

BSR

Simply enter the old domain in the top box and the new name in the bottom box, ensure to tick the ‘Replace GUIDs’ option and do a test run by selecting the ‘Run as a dry run’ before committing to anything.

After a dry run I committed the changes, refreshed a couple of pages and everything seems to be working fine on the new domain and more importantly I don’t need to go through changing tables!

If your looking to move a WordPress installation please take a look at their official instructions

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.