HTTP

Beginners Guide to Automatically Re-directing Your Website from HTTP to HTTPS

Last Updated on

 

Having strong https encryption on your website is extremely important, so much so that google has included your websites encryption status as a ranking signal (see more from google here). So is your website secure?

Recently I shared my website with a friend. His first question was to why the website was not secured with an SSL Certificate (Secure Sockets Layer Certificate).

I responded with: “that is strange – it does have a security certificate that was included in the subscription from BlueHost” (the provider of thewahman.com)

I opened up my website in my own tab, and sure enough it said “Secure”, and was listed as https://

So then, why then was my friend sent to the unsecured version?

The link I shared was – www.thewahman.com, instead of specifically sharing the link with “https://” in the title – https://www.thewahman.com

But that shouldn’t matter, as you have a SSL Certificate so therefore it should be sent to the https:// page.

Wrong.

Without setting up an automatic redirect from http:// to https:// you may be sharing un-secure links without noticing!

So how do you make your website automatically re-direct to the https:// version?

 

There are two options

  1. If you use WordPress, you can install a plugin
  2. You have to change some files on the server

Option 1 is viable, however installs unnecessary code onto your website, and you are always at the mercy of the plugin developer. If the plugin stops being supported, you may have further redirect issues.

I used option 2 as it applies the fix site wide without any support required from a 3rd party. As I am with BlueHost, I will show you what I did, and how you can automatically redirect your page.

If you don’t have a BlueHost, account, you can sign up here (affiliate link – I may receive benefits).

 

BlueHost posts the following advice from their knowledge article:

You can force all of your pages to use HTTPS. To do this you will need to modify your .htaccess file.

Using the Code Editor in the File Manager, add these lines to the beginning of the .htaccess file.

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

Initially without help i did not understand what the code from the knowledge article meant. So, let me visually guide you through the steps that need to be taken to automatically re-direct from http:// to https://.

Step 1: Log into your bluehost account and find where cPanel is. cPanel should be found under the hosting tab. cPanel is a linex based control panel giving users a graphical interface to help manage your webpage.

Under cPanel, you will find the File Manager, which once clicked brings up a menu to let you choose the webiste that you want to adjust. As can be seen in the below picture, I selected the document roots for thewahman.com

Step 2: You will be shown the document directory, and as can be seen, .htaccess is the first file on the list.

Now you just have to open up the .htaccess file and copy the part specified from BlueHost earlier.

Step 3: Insert the following code. You can see the final code at the top of the .htaccess file in the next picture.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.thewahman.com/$1 [R,L]
</IfModule>

Once you have saved the .htaccess file, the website should be successfully re-directing from http:// to https://.

 

Troubleshooting

If you, like me, were having issues finding your .htaccess file in your server, chances are that it is hidden.

An issue that I was having was that the .htaccess file was not showing in my files, but was found when I ran a search. The file could be selected here, but I was redirected back to my normal page (without the file showing up).

So I did some researching, and I would like to credit Alvin from Kickstart Commerce (unaffiliated) who posted a great article on how to fix it. The article can be found here.

The short and sweet version is that you just need to copy and paste:

&showhidden=1&saveoption=1

onto the end of your address bar, once you have logged into cPanel and you are looking at your file list.

Alvin found that there was an issue where the “showing hidden files” feature doesn’t always work. However, using this code solves the problem.

Once you enter &showhidden=1&saveoption=1, the .htaccess file should reveal itself.

 

Related

Posted in Blogging, Earn, Topics.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.