How to force https with .htaccess

After installing an SSL certificate, your website is available over HTTP and HTTPS. However, it’s better to use only the latter because it encrypts and secures your website’s data. While Enchant Services allows users to configure this setting in just one click, you can also use the .htaccess file to force HTTPS connection. This tutorial will show you how:

Once an SSL certificate is installed and the site can be reached via https:// appropriately, you might want to make it accessible via https:// by default. In other words, by typing domain.com in a web-browser, a user should be redirected to https://domain.com to access the site securely.

In this article, we’ll go through some of the basic types of HTTPS-redirection and show how to use .htaccess to Force HTTPS in cPanel.

The file itself can be found if you go to "cPanel >> File Manager". There, find the document root of your website. For primary cPanel domains, the folder is usually "public_html". If the website is an add-on, you can look up its document root in Addon domains section.

When you find the folder, the .htaccess file may already be there. To double-check it, click Settings in the top-right corner and tick Show hidden files (dotfiles).

If the file did not appear, feel free to create it by clicking +File. Make sure to name the file .htaccess, starting with the dot.

To open the file, right-click it, then click Edit. In the next pop-up window, click Edit as well.

  • cpanel, settings
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

SSL Certificates

What is an SSL certificate? An SSL...

Activate Domainkeys and SPF

This article is valid for WHM / cPanel To...

Add IP address to SPF records

When working with SPF records, you may need to add additional IP addresses to...

Addon Domains

An Additional Domain allows a new domain name to be linked to a subdirectory of your account. The...

Antispam System Operation

All our Shared Hosting servers (cPanel Reseller Plans and End Users) are now equipped with a...