Enable SSL in Drupal 8

Information about SSL Certificates can be seen here.

Procure SSL Certificate

  • You will need to analyse your business need and decide on the type of certificate.
  • You will need to buy an SSL certificate, most hosting companies offer such certificates for their customer with respective costs. Based on the hosting plan that you have selected you may also get free SSL certificate for limited duration.

Force SSL - Force your Drupal 8 site to open with HTTPS

Locate and open .htaccess

This file can be opened in VI or any editor of your choice.

Add following lines of code to the end of file

# Redirect to HTTPS

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourwebsite.com [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://www.yourwebsite.com/$1 [L,R=301]

#Replace "yourwebsite" with your actual domain name

These configurations should remain same for any other Drupal 7x / 6x websites or even any php applications hosted over Apache as a web server.