Force http to https WordPress Site

Force http to https WordPress Site

Background:

In this post we will see a common issue where how to move http to https secure protocol a WordPress site. Follow the steps:

Step 1:

Replace Database: Login to PHP My Admin, navigate to your database and click on SQL as shown below:

Following commands need to be executed in SQL command line (Please replace your url “yourOldSiteUrl” and “yournewSiteUrl” in given commands)

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

UPDATE wp_posts SET guid = replace(guid, 'http://yourOldSiteUrl.com','https://yourNewSiteUrl.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://yourOldSiteUrl.com', 'https://yourNewSiteUrl.com');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://yourOldSiteUrl.com','https://yourNewSiteUrl.com');

Step 2:

Open wp-Admin and navigate to Settings>>General tab, you will see your current bese url with http protocol, change it to https and Save. Next Install Better Search and Replace plugin and replace your all old http urls to https.

Step 3: Force https:

Login to cPanel>>File Manager>>Browse WordPress site directory and locate wp-config file. Open file to edit and put following command to enable force https:

define('FORCE_SSL_ADMIN',true);

Note: It might be a case where you see not all your pages are showing secure or url is having https but browser is not showing secure padlock. This is usually called mixed content error, simply browse the page in Chrome which has issue and open Chrome Console, it will show you contents having issue which you can locate and fix manually.

Try to access your site, it should turn SSL compatible and a lock should be visible in Browser.

Leave a Reply

Your email address will not be published.