I have migrated my WordPress blog many times. I have gone from HTTP to HTTPS and back to HTTP. I may likely go back to HTTPS in the future but for now, I am staying with HTTP.

Now, moving your WordPress site to SSL or another ┬ádomain can be tricky. If you don’t do it correctly, you may lose your ranks in Google’s search result pages, block user access to your content and more. I’ve done it few a times and know what works.

Before changing your WordPress site URLs or permalinks please read this first.

There are many reasons why one would want to switch a WordPress blog domain. I had few myself. I switched to HTTPS because Google said so. I later realized how bad it impacted my AdSense income and switched back to HTTP.

So, before switching, please make sure it’s for the right reason. I know I’ve lost a whole lot of ranking switching my WordPress permalinks back and forth. I may get them back but will take a long time.

When you’re ready to migrate your WordPress blog to another domain or go SSL, follow these steps below.

Step 1. Backup your WordPress blog content and database. I you have root access to your Linux server, run the commands below to take a full backup of your database.

sudo mysqldump -u root -p database_name > database_name.sql

(Replace database_name with your WordPress database)

Next, backup your WordPress content, including images. There are many WordPress plugins that may help you backup your database as well as WordPress content.

Step 2. Change WordPress content Permalinks in the database. This is the most important part. You see, WordPress uses database links to reference content. (images, pages, users, etc). When you install WordPress for the first time using HTTP.. all content references will be stored in WordPress database using HTTP protocol.

If you later switch to HTTPS, these references may still keep the HTTP links, even though you changed WordPress site and home URLs to HTTPS.

Some of your images that were uploaded when you were using HTTP may still reference HTTP protocol. If you don’t make the necessary changes in the database, you may get Mix Content warning in your browser.

So, to properly switch WordPress links in the database, run the database commands below.

Sign on to your database using the commands below.

mysql -u root -p

Then run the commands below to update WordPress database post_content table entry to reference the new domain.

UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://www.oldsite.com', 'https://www.newsite.com');

Next, run the commands below to update WordPress database meta table entry to reference the new domain.

UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'http://www.oldsite.com', 'https://www.newsite.com');

Finally, run the commands below to update the WordPress site permalinks.

UPDATE wp_options SET option_value = REPLACE(option_value, 'http://www.oldsite.com', 'https://www.newsite.com');

This can be applied to sites moving from HTTP to HTTPS or back to HTTP.. It can also be applied to site moving to a completely different domain.

Step 3.  Monitor your sites and make sure all is right. if you run into issues, go back and follow the steps above or restore your blog content and database file.

The SQL statements above have been tested on this site with no issues.