How to redirect HTTP to HTTPS

This is a guide, that will show You an easy way to redirect all non-https request to https.

Why would you do this?

Depends on what kind of site you are hosting. For example, if you are running a billing site, and you want to ensure that all traffic is secure.

To force forwarding, there are two easy ways to do this.

  • Using FTP client to upload a new .htaccess file to your Web Root directory
  • Using integrated cPanel File Manager

1) Edit/Create a .htaccess file in the folder your site is being served from (normally public_html).

2) Add the following code to the .htaccess file.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

3) Save the file and check the results in your web browser by trying to access your site using standard http rather than https. If it is working correctly, you should be automatically redirected to https.

Note 1: If there is .htaccess file in directories that are child of Web Root, the last .htaccess file will be executed

Note 2: If You do not have an SSL certificate set up for your site, this will cause errors. Please make sure that you have an SSL certificate installed and properly working before forcing redirection (rewrite).

Useful articles:

Connect using FTP

Edit text/config file with File Manager

Choose the best cPanel hosting plan for your website. Benefit from high level of security and amazing performance.

Get Started!

Also Read

What is ModSecurity?

ModSecurity supplies an array of request filtering and other security features to the Apache HTTP...

Build a website with Drag and Drop using SitePad (formerly SiteMush)

Want to build your personal or business website on your own, but feel like don't have enough...

cPanel: How to make a new subdomain

Subdomains can be used for a new mobile website or just to create a new platform for your...

cPanel: How to create “Out of Office” auto-respond

  Directly to the topic, first, you need to log in your cPanel and after that to find and click...