How to redirect HTTP to HTTPS Using .htaccess and cPanel

How to redirect HTTP to HTTPS Using .htaccess and cPanel

What is HTTPS?

HTTPS Stands for Hypertext Transfer Protocol Secure , Which is an extension of Hypertext Transfer Protocol. It is used for secure communication over computer networks, and is widely used on the Internet. In HTTPS, the communication protocol is encrypted using Transport Layer Security (TLS) or, formerly, Secure Sockets Layer (SSL).


Chrome and Firefox have started showing insecure warnings on sites without SSL certificates. Without SSL, your website will appear insecure to visitors. Therefore, it is necessary to use an SSL-encrypted connection for security, accessibility or PCI compliance reasons. Redirecting from HTTP to HTTPS becomes a must.

website is not secure

What is HTTPS different from HTTP?

Technically speaking, HTTPS is not a separate protocol from HTTP. It is using TLS/SSL encryption over HTTP protocol only. HTTPS is based on the transmission of TLS/SSL certificates, which verify that a particular provider is who they say they are.

When a user connects to a webpage, the webpage will send its SSL certificate which includes the public key needed to initiate a secure session. The two computers, the client and the server, then go through a process called an SSL/TLS handshake, a series of back-and-forth communications used to establish a secure connection.

How to Use HTTPS (TSL/SSL) for Website?

1. Using cPanel :

  • Login in cPanel .
  • Find the Domain Section.
Domain Section
  • Click on Domains.
  • A new page open with Domains list.
  • Click on Force HTTPS Redirect
  • And Turn On
Turn on Force HTTPS Redirect
Turn on Force HTTPS Redirect

Now Your HTTPS Redirect (TLS/SSL)Completed.

2. Using .htaccess File

  • Login your cPanel.
  • In the account Dashboard . Find the Files Section.
  • Go to the File Manager Option. And Open it.
File Manager
  • Now Open the Public html File.
  • Make sure that Show Hidden Files (dotfiles) is checked, and click Save.
View Option Settings
View Option Settings
  • Now Open your .htaccess if you already have one. If not, click File+, name the file .htaccess and click Create New File.
  • Select the .htaccess file, and Right Click and click Edit.
  • If you just created your .htaccess file, use the following code to redirect the URL to the HTTPS version of your website:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www.)?
RewriteRule ^(.*)$$1 [R,L]

  • If your .htaccess file already exists in your hosting account, do not duplicate ReWriteEngine On. Insert the lines beginning with ReWriteCond and RewriteRule directly after the already existing ReWriteEngine On.
  • Click Save Changes and Close. 
  • Visit your website and you will automatically be redirected to the HTTPS version.

Watch this Video for More Understanding :

One thought on “How to redirect HTTP to HTTPS Using .htaccess and cPanel

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!