How to Change HTTP into HTTPS in WordPress

Change HTTP into HTTPS

After configuring SSL settings of the web server, now here comes a question: how can we change all HTTP URL into HTTPS URL ones in our WordPress site?

I know there're many plugins can do this, but mine is very quick and straightforward as long as you are able to connect to your MySQL database and issue UPDATE statements. No need to install any plugin.

There're at least 8 columns need to be replaced. Please backup your database before doing this.

update wp_blog_commentmeta set meta_value = replace(meta_value,'http://yourdomain.com','https://yourdomain.com'); update wp_blog_comments set comment_content = replace(comment_content,'http://yourdomain.com','https://yourdomain.com'); update wp_blog_options set option_value = replace(option_value,'http://yourdomain.com','https://yourdomain.com'); update wp_blog_postmeta set meta_value = replace(meta_value,'http://yourdomain.com','https://yourdomain.com'); update wp_blog_posts set post_content = replace(post_content,'http://yourdomain.com','https://yourdomain.com'); update wp_blog_posts set guid = replace(guid,'http://yourdomain.com','https://yourdomain.com'); update wp_blog_posts set pinged = replace(pinged,'http://yourdomain.com','https://yourdomain.com'); update wp_blog_termmeta set meta_value = replace(meta_value,'http://yourdomain.com','https://yourdomain.com');

The key of the solution is to use MySQL REPLACE() function to change all occurrences of the column and then use the new content to update itself.

Please note that, wp_blog_ is the table prefix and yourdomain.com is the domain name, please replace them with yours.

Since I use Redirection plugin for managing old permalinks, so I also changed some data on its table.

update wp_blog_redirection_items set action_data = replace(action_data,'http://yourdomain.com', 'https://yourdomain.com');

There're could some content created by other plugins needed to be replaced with, you can do it in the same way.

If everything goes well, you can redirect all incoming visits to HTTPS.

Leave a Reply

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