0

I have a WordPress site up and running at siteA.com and an empty parked domain at siteB.com. Ideally, I would like siteB.com to become the definitive location for the site for both the public and site editors.

My web host* offers domain mirroring. Can I set siteB.com to be a mirror of siteA.com without losing any WordPress functionality or causing broken links? What if I were to also go into WordPress Admin > Settings > General and change both the WordPress Address (URL) and Site Address (URL) to siteB.com? Would site editors be able to log in at siteB.com?


*Dreamhost, if that's helpful.

0

Migrations are really tricky because they could be really easy or a pain in the ass. (If you want a fast solution just skip the explanation and go to the Fast solution).

The easy part

When you are migrating your website you will need to use MySQL and access to your PHPMyAdmin.

Once you login to your PHPMyAdmin you need to find your new database with the old.com urls and click the "SQL" tab.

There you will paste this SQL:

  UPDATE wp_options
  SET option_value = replace(option_value, 'http://old.com', 'http://new.com')
  WHERE option_name = 'home'
  OR option_name = 'siteurl';

  UPDATE wp_posts
  SET guid = replace(guid, 'http://old.com','http://new.com');

  UPDATE wp_posts
  SET post_content = replace(post_content, 'http://old.com', 'http://new.com');

  UPDATE wp_postmeta
  SET meta_value = replace(meta_value,'http://old.com','http://new.com');

Heads up! Remember to change every old.com with yourOldUrl.domain and every new.com with yourNewUrl.domain. Ex. old = testing.com | new = production.com

To really fast walk you through this code, you have to know that there are three tables where we have stored our urls on a normal/easy migration: wp_options,wp_posts,wp_postmeta; and this code simply replace one string to another.

What could possibly go wrong?

If you have a custom theme or plugins that stores data in different tables (normally wp_options) and if they store serialized data (and they do!), that would be a real pain in the ass because serialized data is an array stored as an string and if you change any text's length (old.url = 7 characters vs mynew.url = 9 characters) It will cause an error and won't recognise the string as a serialized string anymore.

Read more about serialize data here.

Fast Solution

I always migrate every project from it's testing environment to the production server so I made this library to make my life easier.

It will help you to migrate urls from one server to another in just one click.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.