Drupal 8 Force https Redirect Enabling SSL

Drupal 8 Force http to https Redirect

Drupal 8 Force http to https Redirect 1024 640 Jesandy

Drupal 8 Force https Redirect – When you are using Drupal 8 most of everything working manually, including if you encrypt your SSL on your website. Particularly you already set up SSL on your hosting, but when you try or accidently type manually your domain without https://, it just not working. In other word on your browser your website mark as insecure (without the lock icon:)

So herewith how to make your website, Drupal 8 force https redirect. In my case my website SSL already encrypted and now we just go to our cpanel to change what we want to be. I used “Lets encrypt SSL” or the one that my hosting provider for free. And please be careful, every server or hosting may have different method, the way to solve your problem may vary depend on the hosting or server provider.

Enabling HTTPS on Your Drupal 8

First go to Cpanel, on your public html folder find file name .htaccess (text) and open that file. Notes: in some cases the .htaccess file is hidden, make sure you go to setting and “Show Hidden Files“. After you open the .htaccess file, at the bottom just copy and paste the code below


# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

And Saved.

Right now your website must be using https

 

Another Example how to force https from H2 Hosting:

You can use .htaccess settings to automatically redirect users to secure (https://) web site connections, even if they type a non-secure URL (http://) in their web browser.
Additionally, you can use .htaccess settings to automatically redirect users who do not include the www prefix. For example, many third-party SSL certificates are only valid for one specific domain, so web site owners often set up an SSL certificate for the www subdomain (www.example.com). However, this means that visitors to the site may receive a security warning if they go to example.com without the www prefix. An .htaccess directive enables you to prevent this from occurring.

Jesandy

"Jesus Believer, Founder of Bebright Indonesia, seolangit.com and aviamedic.com Digital Marketers, Brand Marketing Consultant, Game Reviewer, @zadewagaming contributors, Traveler, Movie Freaks, Pizza Lovers, SEO & Social Media Specialist, Webmaster and Drupal Enthusiast"

All stories by: Jesandy
1 comment

Leave a Reply

Your email address will not be published.