Understanding how links will work when DNS changed to point to new WordPress site

Old question, but for the record:

Provided that you adjust the WP_HOME and WP_SITE urls appropriately, the page links should work just fine when you migrate.

An easy way is to add the following lines to your wp-config.php file after uploading the site to therealwebsitename.co.uk:

define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

You’ll then be able to then login to wp_admin and in Settings>General change the values. This will update the database, then you can remove the two lines you added from wp-config.php.

Media is a different story, depending on how you’ve set up WordPress. I use the great Search Regex plugin to go through the database and change all references to old media, and switch them to new:

  1. You’re migrating your site, so you already have a DB backup
  2. Go to Admin > Media > Library and Edit an image
  3. copy the File URL on this page
  4. trim this URL so that you have something like test.blahsystems.co.uk/wp-content/ (you don’t want the http:// or anything after wp-content/)
  5. Go to Tools > Search Regex and enter this URL into the search field
  6. in the replace field enter the adapted URL, something like: therealwebsitename.co.uk/wp-content/ (make sure that the slashes on the end match)
  7. hit Replace. This will preview the operation, and no change will be made until you hit Replace & Save.
  8. Compare the previewed operation and check that it looks correct, then Replace & Save!
  9. Test the links – generally works flawlessly first time, but fiddling is no less painful. (note that some themes may put links in excerpt as well – you may need to repeat this operation with Source set to Post Excerpt)

Search Regex Preview

A separate issue that your host may be referring to may involve mapping your old sitemap to the new, so that your don’t lose link juice. An easy way to manage this issue is with the plugin Redirection by Urban Giraffe. As a bonus, it can auto add redirects for you if you change any page slugs subsequently.

Hope it helps someone 🙂