In order to get a secure connection (also called SSL or https) on your website the easiest way is to use Cloudflare. I will explain it step by step in this tutorial.

Easy (and free) https for your Drupal website

20/11/2015 - 13:30

Cloudflare

  • Sign up for Cloudflare.
  • After you've signed up you can log into Cloudflare.
  • Choose 'Add site'.
  • Enter the URL of your site and click on 'Begin Scan'. Cloudflare will now try to determine the nameservers for the entered domain name.
  • Once finished Cloudflare will show you all the details about your domain name. You can click on 'Continue'.
  • It's time to choose your Cloudflare Plan. If you just want SSL (https) select the 'Free website' plan and click continue.
  • Now here is the tricky part: you need to change the Nameservers of your domain name to the ones provided by Cloudflare on this screen. 
  • Go to the 'registrar' of your domain name (your should have a URL to an online console somewhere). Login and change the nameserver.
  • Don't know who your registrar is? You can check it out on this website by entering your domain name. 
  • Some registrars don't give you the option to change your nameserver(s). You might have to e-mail them and ask if they can change it for you.
  • After you've changed the nameservers of your domainname go back to Cloudflare and click 'continue'.
  • When you see 'Status: pending' you just have to wait and come back later because the changes in your nameservers still need to be processed by your registrar. If this takes longer than 24 hours contact them again.
  • In the most likely event you will see that the status is 'Active'.
  • Now click on the button 'Page Rules' on the top.
  • Enter the following as a URL pattern (replacing domainname.com with your own domain name):
http://*.domainname.com/*
  • Toggle 'Always use https' so it's switched on and 'Add rule'.

Drupal configuration

As you visit your website you will see it's now https. There's just one thing left to do. You need to change the 'base url' of your Drupal website so images will also load with https. If you don't change this your page wont be fully secure because images will still be loaded with http.

  • Connect with (S)FTP to edit your Drupal files.
  • Go to your settings.php which is most likley located at:
/sites/default/settings.php
  • Search for the following line:
# $base_url = 'http://www.example.com';  // NO trailing slash!
  • Remove the '#' and change the http into https and enter your own domain name resulting in:
$base_url = 'https://www.domainname.com';  // NO trailing slash!
  • Safe the file and your website should now be fully secure with SSL and https!

Want to become a Drupal Expert?

Subscribe to my newsletter and receive e-mails with the latest Drupal tutorials, tips and tricks.