2 Solutions for still showing “not secure” via HTTPS (with SSL)

Overview

A common issue after adding an SSL certificate is that your browser still shows your site as insecure. This most often happens because there are links on your page that still point to HTTP instead of HTTPS. For example, look at the following code to link an image.

<img src=”http://www.example.com/images/pic_mountain.jpg” alt=”Mountain View”>

Notice how the URL is directly linked with ‘http’ at the beginning. When visiting the site in Firefox, the following is displayed:

You can see the padlock icon in the top left of the browser shows a warning icon instead.

Cause of this error

If you click on the warning icon the text explains that there are ‘unencrypted elements’ on the page you’re viewing.

From the example above, this is happening because the image was linked using ‘HTTP’ and not ‘HTTPS’. Another way to confirm what on your site is linked insecurely is to use the following site:

Fixing unencrypted links

Solution 1

Use absolute links

Absolute links are the full url location to your file. This includes the domain name. For example:

<img src=”https://www.example.com/images/pic_mountain.jpg” alt=”Mountain View”>

Just make sure you’re using HTTPS when linking this way.

Use relative links

Relative links do not include the domain name. These links point to a local file instead. For example:

<img src=”images/pic_mountain.jpg” alt=”Mountain View”>

Solution 2 – Recommended

Resolving the warning by adding code to your .htaccess file

Instead of manually updating links in your code, you could add the following lines to your site’s .htaccess file.

  • Creating and editing a file via FTP
  • .htaccess overview

Header always set Content-Security-Policy “upgrade-insecure-requests;”

These lines force the browser to automatically update any insecure links to secure links. Once added, the warning should immediately disappear.

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.