How to install WordPress on NearlyFreeSpeech – Part 3 – HTTPS/SSL

The first post helped you get your NFS database set up. The second post got WordPress installed. And this third post will show you how to serve your WordPress site via HTTPS/SSL.

Using TLS / HTTPS can be tricky to get configured. First, make sure you don’t have an .htaccess file in your root redirecting traffic to HTTPS while you are installing WordPress. If you do have it you’ll get funny errors when trying to access the admin login page. Just rename it for the time being until you get this bit working, then change it back to .htaccess.

To configure WordPress to run under HTTPS make sure that you’ve set up and enabled SSL for your site, and that it’s working – but as noted don’t force redirection for the minute.

Add this to the end of wp-config.php:

In your WordPress dashboard, under Settings > General, update your “WordPress Address (URL)” and “Site Address (URL)” from “HTTP” to “HTTPS”.

Redirect Loop
Note that when you make the change to the site names under Settings > General, it can occasionally result in a redirect loop error. You’ll no longer being able to access the wp-admin pages. To fix this (from here: https://codex.wordpress.org/Changing_The_Site_URL) you can edit the settings via phpMyAdmin. Go to your database table ‘wp-options’ and change the ‘siteurl’ and ‘home’ values.

Or you can manually change the sites back to what they were before by putting these two lines in the wp-config.php file then you can get back into the settings page and turn back to HTTP before removing these from wp-config.php and troubleshooting the problem:

Insecure Assets
There is another common issue whereby, just after you turn on HTTPS you get an error from your browser when you visit the site on HTTPS which warns you about some of the site’s asseets loading from an insecure location.

This happens because the domain is on HTTPS and there is a cert for the domain, but Chrome was blocking all of the scripts and css files in the source code that were being called from HTTP. To fix this we need a WordPress plugin which will go into my source and convert all the HTTP urls into HTTPS urls if the user was hitting the site via HTTPS://

Use the “SSL Insecure Content Fixer” plugin to fix this: http://wordpress.org/extend/plugins/ssl-insecure-content-fixer/ .

And we also need to add in our own custom plugin to let the server know when a user is accessing via HTTPS. To do this access your root/wp-content/plugins directory via SSH then create a file called force-ssl-url-scheme.php and add this content:

Run the following commands again to make sure the permissions of this new plugin are correct:

Now go into your WordPress admin screen and enable this new plugin.

TTPS/TLS access is tricky to get completely correct. For instance, for some reason I had a lot of trouble even after following these steps with trying to get my WordPress wp-admin pages loading in HTTPS but others have had absolutely no issues with this. Google will ultimately be your best friend in diagnosing those ‘unique’ issues that always seem to crop up.

Leave a Reply

(email optional)