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 a skilled programmer specializing in Vue.js/Nuxt.js for front-end development and PHP Laravel for back-end solutions. I have a strong focus on API design and development, complemented by experience in web server setup and maintenance. My versatile expertise ensures seamless creation and maintenance of web applications, covering everything from intuitive user interfaces to robust server-side functionality. Passionate about coding and driven by a lifelong learning mindset, I invite you to explore more at danyal.dk.