It's no News that most browsers are now placing great priority on SSL certificates. websites that do not have an SSL certificate in the HTTPS prefix in front of their domain name are going to be failing the basic security standard for internet browsing, because, without SSL, your website will show the warning sign to your web visitors, a good example will be the illustrative image below. Therefore, using an SSL-encrypted connection for safety, accessibility or PCI compliance reasons is necessary. It becomes very important to redirect from HTTP to HTTPS. 

Using the redirect HTTP to HTTPS via the .htaccess method, you can have a much more secured 301 redirect that you can easily edit with a few lines also this is also called IP CANONICALIZATION or 301 REDIRECT.

seo web analyst blogger community

What is SSL?

First, before we take off, it will be better we define what SSL is, SSL (Secure Sockets Layer) is a standard security protocol for establishing encrypted links between a web server and a browser in online communication.

The usage of SSL technology ensures that all data transmitted between the web server and browser remains encrypted.

An SSL certificate is necessary apart from its SEO benefits it is also used to create a Hypertext Transfer Protocol Secure aka HTTPS connection. You would need to give all details about the identity of your website and your company when you choose to activate SSL on your web server. Following this, two cryptographic keys are created — a Private Key and a Public Key.

We have different ranges of SSL CERTIFICATES from wild cards (used on every subdomain variation of a domain, the highest level count is 250 subdomains) to (OV) and (EV) SSL (formerly used to represent the green bar with The Company's name) which was later discovered to make no difference, and since the entire experimentation is now geared towards every website owner having an HTTPS, web browsers now distinctively display the insecurity warnings for URLs that do not have the HTTPS.

However, one question that needs to be considered first: what type of certificate is best to choose - OV or EV? What is the difference between these two SSL certificates?
OV-certificate (Organisation Validation) is a certificate that confirms the existence of the organization. To get an OV certificate, the company must complete the validation process.
While the EV -Certificates provide the organization with a branded company name's green bar (This, unfortunately, has been discontinued due to low impact and zero influence from it), getting an EV-Certificate is not as complicated as registering for OV-Certificates.

In order to force your web traffic to use HTTPS, edit the codes in the .htaccess file.

Before we move on to redirecting HTTP to HTTPS, here’s how you can edit .htaccess file. If you already know skip to the Redirection steps.

Editing .htaccess File

There are instructions/directives in the .htaccess file that tell the server how to act in certain scenarios and directly affect how your website functions. Common directives in .htaccess file:

  • Redirects
  • Rewriting URLs

Ways to edit an .htaccess file:

  1. Edit the file on your computer and upload it to the server using FTP.
  2. Use “Edit” mode in FTP program that allows you to edit a file remotely.
  3. Use a text editor and SSH to edit the file.
  4. Use the File Manager in cPanel to edit the file.

Editing .htaccess in cPanel File Manager

Note: Backup your website in case something goes wrong.

  1. Login to cPanel
  2. Files > File Manager > Document Root for:
  3. Now select the domain name you want to access
  4. Check “Show Hidden Files (dotfiles)”
  5. Click “Go”
  6. After a new tab or window opens, look for the .htaccess file.
  7. Right-click on the .htaccess file and click on “Code Edit” on the menu.
  8. A dialogue box may pop up asking about encoding. Click the “Edit” button to continue.
  9. Edit the file
  10. “Save Changes” when done.
  11. Test your website to make sure it is done correctly. In case, there is an error, restore to the previous version and try again.
  12. Once you are done, click “Close” to close the window.

Redirecting HTTP to HTTPS

1. Redirect All Web Traffic

If you have existing code in your .htaccess, add the following:

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

2. Redirect Only a Specific Domain

For redirecting a specific domain to use HTTPS, add the following:

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

3. Redirect Only a Specific Folder

Redirecting to HTTPS on a specific folder, add the following:

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

Note: Replace “yourdomain” with your actual domain name, wherever required. Also, in the case of the folder, replace /folder it with the actual folder name.

Recommended: How To 301 Redirect, (AVOID DUPLICATE CONTENT SEO).