Drupal: How to enable HTTPS support in Drupal

In order to enable https on Drupal site, you need to implement following .htaccess snippet. Obviously, I assume that you have access to the Server SSH/FileManager or FTP and SSL is installed & configured for your site already on the server.

From .htaccess of your site root folder uncomment the following:

#1
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Then to redirect all http:// to https:// implement following snippet in .htaccess file.

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

That’s all you nee to do, and you are good to go.

Author: Danyal
I'm skilled programmer with expertise in Vue.js/Nux.js for front-end development and PHP Laravel for back-end development. I excel in building APIs and services, and also have experience in web server setup & maintenance. My versatile skill set allows you to develop and maintain web applications effectively, from the user interface to the server-side functionality. I love coding with never ending learning attitude, thanks for visiting danya.dk