How To Force SSL On All Pages In .htaccess File

How To Force SSL On All Pages In .htaccess File
Introduction
This is a quick step-by-step walkthrough for forcing your site to load via HTTPS, instead of HTTP.
We recommend all websites relying on SSL encryption take these steps to guarantee your website traffic is using an encrypted connection.
How To Force SSL On All Pages In .htaccess File
STEP 1
Locate your .htaccess file
Firstly, you need to locate your .htaccess file using your preferred FTP client. This will be in your /httpdocs folder.
Be aware that .htaccess files are classed as ‘hidden’ files, so you may need to make sure hidden files are visible via your FTP client’s settings.
When you have found the .htaccess file, you’ll need to download it to your local machine and open it in your favourite code editor.
Again, because .htaccess files are hidden files, the file may not be visible after you have downloaded it. For Mac users, just open Finder and press CMD + SHIFT + ., to toggle hidden files on. ( How To Force SSL On All Pages In .htaccess File )
STEP 2
Force all traffic to use HTTPS
To force all traffic on your domain to use HTTPS, simply add the following. If you have existing code in your .htaccess file, you should add this above your current rewrite rules.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Recommended Posts

STAND WITH UKRAINE
February 28, 2022