How to Configure WordPress to Use an SSL Cert

How to Configure WordPress to Use an SSL Cert

In today’s world EVERY site needs to be served over https. Don’t take just my word for it – take the word of one of the biggest internet companies around: Google. Take a look at their developer’s article titled: Why HTTPS Matters.

Below are the step by step instructions on what to do once the SSL certificate is installed. Got a question? Feel free to ask by posting a comment below.

Step One – Install cert. (Let’s encrypt is automatic)
Step Two – Go to “Setting” -> “General” -> change the WordPress-adress (URL) + Siteadress (URL)
Step Three – Force https via htaccess file. (Code included at bottom of this post)
Step Four – Fix mixed content issues with the plugin Better Search Replace and then uninstall the plugin. (Search: http://www.example.com or http://example.com / Replace: https://www.example.com or https://example.com )
Step Five – Update site in google and bing webmaster tools
Step Six – Sit back, relax and have a cold drink as you are done.

Down below are two sets of code. The first set is to redirect to https://www. And the second set is to redirect to https:// (if you are doing this on a live site then do NOT switch from www to naked or vise versa as it will mess with SEO)

Keep in mind that both set’s of code will work for most cases if you have a single site in your account (it’s not suggested to have more than one site per account for security reasons.) or each site within your account have their own domain name and they all follow the same rules. (i.e. all use www or all are naked domains.) If you have a special case feel free to comment below with what your environment entails and I’ll try to help as best as I can.

Additional notes – Ignore anyone saying to use a plugin like Really Simple SSL. Do it right the first time and you won’t have to worry about fixing it down the road if your site needs to scale big.

Force https://www.example.com

Copy to Clipboard

Force https://example.com

Copy to Clipboard
By |October 30th, 2017|Security|9 Comments

About the Author:

Brian Hochstein has been in and out of the hosting and web design arena as a hobby for over 15 years and has gotten back into it seriously again since 2014. His knowledge ranges from HTML, CSS, some JavaScript and PHP to server administration, computer repair and branding.

9 Comments

  1. Brian Hochstein January 30, 2018 at 9:37 am - Reply

    This code was updated 30JAN18 as soon as it was brought to my attention that when using the naked to www + http to https code snippet if you were to try accessing the site via “www.example.com” the redirect would result in having an extra ‘www’ in the url. I have tested the new code on my this site and it appears to be working like it should. If you find that it is not working as it should please let me know as soon as possible.

  2. Robin Bakker May 30, 2018 at 12:26 am - Reply

    Hi Brian,
    Awesome guide, now I can get rid of another plugin and make WordPress installs lighter! Maybe a couple suggestions: Step 2: Go to “Setting” -> “General” -> change the WordPress-adress (URL) + Siteadress (URL)

    Make the text bold or larger for which set is intended to do what :
    “THE FIRST SET is to redirect to https://www. And THE SECOND SET is to redirect to https..”

    Just to make it dummyproof 🙂
    Again thanks! Looking forward to implement this on other WordPress installs!

    • Brian Hochstein May 30, 2018 at 1:42 am - Reply

      @Robin Bakker – Glad you found it useful! Also, thanks for the suggestions. I’ve implemented them. 🙂

  3. Slane June 14, 2018 at 7:39 am - Reply

    Do you have an example when the Webserver is MS IIS?

    • Brian Hochstein June 15, 2018 at 9:34 pm - Reply

      Hello Slane,

      I don’t have any examples geared specifically for an IIS server. Ideally it is suggested to not run a WordPress site on a windows server as it’s not really designed for one. If you can I’d say move to a linux based host.

      If you can’t migrate to a linux server – here is a write up for how to do redirects on an IIS server: https://blogs.msdn.microsoft.com/kaushal/2013/05/22/http-to-https-redirects-on-iis-7-x-and-higher/

      I’m not sure if the search and replace will work or error out. The rest should probably be the same.

  4. Donna Richards July 2, 2018 at 6:52 am - Reply

    Do I install the SSL on the staging long domain name first? Or do I go into general settings and change there first to real domain name, and then force HTTPS?

    • Brian Hochstein July 3, 2018 at 1:57 pm - Reply

      Hello Donna,

      You are talking about two different areas here. A staging area and a live production site.

      Is the live production domain name already pointed at that server or does the site need to move to the server where the domain is pointing?

      Are you wanting to take the site live right now or is it not ready yet?

      Once those two questions are answered I can better assist you with your specific use case scenario.

  5. Robin Bakker July 5, 2018 at 5:22 am - Reply

    Hi Brian, What if the site http://www.example.nl links to http://www.www.example.nl (so a double WWW) Any idea how I can fix this?

    • Brian Hochstein July 5, 2018 at 3:25 pm - Reply

      Hello Robin – can you show me what you have in your htaccess file?

Leave A Comment