How to Enable SSL in Drupal 8

Updated on Mar 13, 2019

Having an SSL certificate for your domain and enabling Drupal 8 to work via HTTPS is important for your website and your visitors. This gives you more credibility and shows your users that they can trust the content on your website and not worry about their personal sensitive information (passwords, credit card numbers etc).

To activate SSL in Drupal 8, you need to complete the following steps:

step

Obtain an SSL Certificate

The first thing you will need is to have a valid SSL certificate for your domain. To purchase an SSL certificate, you will have to login to your Client Area and navigate to Orders -> Product Addons and select the Personal 256bit SSL Certificate. After that, submit a ticket and our Technical Team will gladly activate the certificate for your domain. Or get a free Let's Encrypt SSL issued for your website via cPanel.

step

Force SSL

To force the connection via HTTPS you will need to open up the .htaccess file by using your cPanel's File Manager (select show hidden files (dotfiles) or enable this once you are in File Manager via the Settings menu).

Accessing the FIle manager via cPanel

Now navigate to the location of your Drupal 8 installation, click on the .htaccess file and the select the Code Edit option.

Editing the htaccess file of Drupal 8

Find the code line:

RewriteEngine on

And add this code snipped below it:

# Redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

You can also add this line to the end of your .htaccess file if you have other custom rewrite rules that you want to work independently of this one.

Congratulations, you have successfully enabled a secure connection to your website.

On this page...

    Drupal 8 Hosting

    • Free Drupal 8 Installation
    • 24/7 Drupal 8 Support
    • Free Domain for life
    • Hack-free Protection
    • Fast SSD Storage
    • Free Drupal Transfer
    • Free CloudFlare CDN
    • Immediate Activation
    View More