Force SSL/https using .htaccess

You can force an HTTPS connection on your website by adding these rules in your website's .htaccess file:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

The .htaccess file needs to be located inside the site's document root folder. If your website is in a sub folder, then the .htaccess should be placed in the corresponding sub folder.

You can create or edit the .htaccess file either via FTP, or using with the File Manager available in cPanel.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to block access to a specific folder?

To block all access to a specific folder in your account, you should add this rule to the...

How to protect your account from TRACE request attacks?

In order to protect your account from HTTP TRACE request attacks, you can add this to your...

How Do Websites Get Hacked?

The most common reasons for a hacked (defaced) website include: Outdated web application....

What is a Brute Force Attack and how to block it

Brute Force is a method of guessing your password by trying combinations of letters, numbers and...

How to clean malicious code from your website?

If your website has been hacked and malicious content has been inserted into your files, you...