WordPress Migrate from HTTP to HTTPS

Posted on January 30, 2017 at 12:32 am

Simple guide to migrate WordPress from HTTP to HTTPS:

1) Install free SSL certificate with Lets Encrypt

2) Enable SSL HTTP/2 for best performances

3) Change WordPress Site URL

Open the Dashboard->Settings->General.

Change http://www.yoursite.com to https://www.yoursite.com

4) Replace all http:// to https:// in post contents

Use these MySQL queries to do the hard work:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.website.com', 'https://www.website.com') WHERE option_name = 'home' OR option_name = 'site url';
UPDATE wp_posts SET guid = replace(guid, 'http://www.website.com','https://www.website.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.website.com', 'https://www.website.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.website.com','https://www.website.com');

5) Update all hard-coded Links to HTTPS

Replace all hard-coded HTTP links http://www.yoursite.com to HTTPS links https://www.yoursite.com in all .php and .html files located in your WordPress theme’s folder and in all other custom .php or .html files on your website.

6) Update CDN links and AJAX\JS libraries to HTTPS

Replace all JS scripts and external CSS links with https:// or //, i.e:

//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css
//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js
//fonts.googleapis.com/css?family=Open+Sans:400,300,700

7) Redirect http:// to https:// on your web server

Example .htaccess file for Apache server:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]

Example redirect for Nginx server:

server {
        listen 80;
        server_name example.com www.example.com;
        access_log off;
        error_log off;
        return 301 https://www.example.com$request_uri;
}

8) Test SSL certificate

Use SSL Server Test to test HTTPS security and performance.

Another good SSL-test service is: SSL Server Security Test

Use Pingdom Website Speed Test to test website page load speed.

Have questions? Leave a comment.

Receive updates via email

Other Posts

Updated Posts