Force SSL With HTACCESS & Meta Tags To Fix Mixed Content

HTACCESS SSL Mixed Content

So, you have a shiny new SSL certificate for your website and now need to force SSL but you keep getting mixed content errors. This simple post will consist of two parts and should get you up and running with a “green lock” in no time.


Step 1 – You Need To Modify Your .htaccess File By Inserting The Below Code:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Step 2 – Insert The Following Code Into The “META” Section Of Your Website Header:

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

That should cover it, now your website should load with the “green lock” as well as force the loading of non-secure elements to load over “https://”. Let us know how this solution worked for you in the comments.

Back to Blog

Leave a Reply

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