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]


STEP 3
Upload your updated .htaccess file

Once you have updated your .htaccess file, you need to upload it back into your /httpdocs folder

hosting htaccess
hosting htaccess

.

Please note: We strongly recommend making a backup copy of your existing .htaccess file before overwriting it.

Leave a Reply

Your email address will not be published.

WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
👋 Hi, how can I help?