Categories
guides

Adding/Installing SSL/TLS/HTTPS

Some of these steps can be completed via command line with wp-cli if installed by using commands generated from this tool. To find out if wp-cli is installed, try running wp cli version.

Adding the Cert

These instructions are for SiteGround hosting with a free Let’s Encrypt certificate. Other hosts support of Let’s Encrypt and steps will vary.

  1. Login to SiteGround admin
  2. Select the Management account that includes the hosting domain
  3. Go to cPanel
  4. Click Let’s Encrypt from Security section
  5. Select domain, tick Let’s Encrypt SSL, and click Install
  6. Test HTTPS connection

Updating resource links to https

Consider using wp-cli and commands generated by this tool instead for a quicker simpler and more secure approach.

  1. In cPanel, select phpMyAdmin from Databases section
  2. Export backup of MySQL db
  3. SSH to server
  4. Copy SRDBM to root folder (download here)
  5. Perform the following Dry Run search and replace tasks, and perform Live Run if no errors. NOTE: See bottom of these instructions if CLI f/r required
    • Find out if preferred sub-domain is @ or www – f/r to the preferred one
    • http%3A%2F%2Fdomain.tld to https%3A%2F%2Fdomain.tld
    • http:\\/\\/domain.tld to https:\\/\\/domain.tld
    • http:\/\/domain.tld to https:\/\/domain.tld
    • http://domain.tld to https://domain.tld
  6. Test for green padlock
  7. DELETE SRDBM

Check config

Check in wp-config.php file for the following, update to https if necessary:

define('WP_HOME', 'http://domain.tld');
define('WP_SITEURL', 'http://domain.tld');

Forcing HTTPS Connection via .htaccess

  1. SSH to server
  2. Make backup of .htaccess file
  3. Add rewrite rule: RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://domain.tld/$1 [R=301,L]
  4. Test forced HTTPS

Forcing HTTPS Connection via Apache .conf file

  1. SSH to server
  2. Make backup of .conf file
  3. Change *:80 vhost to: <VirtualHost *:80> ServerName domain.tld Redirect / https://domain.tld/ </VirtualHost>
  4. Test forced HTTPS (confirm works with any URL)

Using SRDBM from command line

php srdb.cli.php -h "localhost" -n "db_name" -u "db_user" -p "db_pass" -s "http:\/\/domain.tld" -r "https:\/\/domain.tld" -z

The -z switch is for dry run, be sure to re-run without if no errors.

By bo.

I'm @boyEatsSteak in a lot of places. I have been wanting 🍕 for weeks. I like gadgets and technology and keeping notes and tips for my future self since all I can remember is that I forget things.