How to fix mixing of secure and insecure content on a web page

This article describes an issue that occurs when visitors to your web site request a secure web page that contains insecure elements.


When visitors to your web site request a page using a secure https:// connection, a broken padlock icon may appear in the web browser's location bar. Additionally, they may receive a warning message in their browser:

  • Mozilla Firefox displays:
    “The connection to this website is not fully secure because it contains unencrypted elements (such as images).”
  • Microsoft Internet Explorer displays:
  • Google Chrome displays:


This problem occurs because a web page contains hyperlinks to insecure elements. For example, consider a web page that contains the following HTML snippet:

<a href="">View my picture</a>

In this HTML snippet, the hyperlink references a non-secure http:// resource (a .jpg file). If a user requests this page using an https:// connection, the page itself is encrypted, but the hyperlinked image file is not. As a result, the page contains secure and insecure content, and the browser displays a warning message to the user.

This problem can occur with any type of hyperlinked resource file: a JavaScript library, a CSS file, etc.


There are a few ways you can resolve this problem:

Method #1: Send a Content-Security-Policy response header directly from the web server

To resolve this problem, you can send a Content-Security-Policy HTTP response header. This header instructs web browsers to upgrade insecure requests to HTTPS.

For Apache web servers on Linux, add the following lines to the .htaccess file (or files) that you use on your website:

<IfModule mod_headers.c>


Method #2: Send a Content-Security-Policy directive from page source files

Alternatively, you can use the following meta tag in the source files of your site pages:


More Information

For more information about the upgrade-insecure-requests directive, please visit

