How to redirect HTTP to HTTPS

Google chrome and Firefox browsers will make your website look insecure without ssl certificate. This can lead to a bad attitude of visitors towards your website. Moreover, it is important to keep the website in a good position of SEO. Click here to know how to get SSL certificate. Even after ssl is launched, it will not take our website directly to https. We will learn now that we have to take some different steps for this.

The difference between http and https.

  • http is the hyper text transfer protocol. Which is a popular and widely used method of exchanging information on the Internet.
  • https is a hyper text transfer protocol secure. Which is currently the most used method. The https method is very secure. so, there is no third party monitoring in the way the information is exchanged.

How do I know if my (ssl) https is on or off ?

  • First we will type “http://example.com” ( without https:// ) in the address bar of Google Chrome or Firefox. If “not secure” text is displayed. Then again, after dialing “https://example.com” ( with https:// ) the lock sign or secure text appears. However, understand that you have ssl or https turned on. But it is not being redirected to https automatically. Which is shown in the screenshot below

First we will type “http://example.com” ( without https:// ) in the address bar of Google Chrome or Firefox. If “not secure” text is displayed. Then again, after dialing “https://example.com” ( with https:// ) the text “Your connection is not provided” is displayed. However, you must understand that your Ssl is not turned on. Which is shown in the screenshot below. Click here to know how to get SSL certificate.

How can we easily redirect to https automatically ?

You can easily do this by putting some code in the .htaccess file. The way the work can be done is mentioned below

  1. Upload a file to the server using FTP.
  2. Edit .htaccess file using FTP.
  3. Edit .htaccess file using Cpanel file manager.

Edit .htaccess file using Cpanel file manager or FTP.

  1. ==>> At first go to your root folder via using FTP or Cpanel Via “example.com/cpanel”
  2. ==>> Then Login Your Cpanel.
  3. ==>> File Manager.
  4. ==>> Public_html
  5. ==>> Settings
  6. ==>> Show Hidden File
  7. ==>> Save
  8. ==> .htaccess
  9. ==>> Then The Flowing Code and Save Change.

1. Redirect all web traffic by flowing this code.

If you use this code. Then all visitors will be redirected to https.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

2. Redirect Only a Specific Domain traffic by flowing this code.

If you use this code. Then Only a Specific Domain visitors will be redirected to https.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

3. Redirect Only a Specific folder traffic by flowing this code.

If you use this code. Then Only a Specific folder visitors will be redirected to https.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]

In this case, you must put your domain name in the place of example.com and put the name of your folder in the place of folder. Once the work is done, check yourself once to see if your work is done.

Leave a Reply

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