12

When attempting to view my site over https, I keep getting a "Blocked loading mixed active content" error in my Firefox console. I am getting this error only for my css and js file.

The reason I am so confused is because the reference to the files in the page code itself is https:

<link rel="stylesheet" href="https://www.example.com/style.css">

But in the console, it shows it as http:

Blocked loading mixed active content "http://www.example.com/style.css"[Learn More]

I can do a view source on the page and search for "http://" and there are no results anywhere on the page.

Any ideas?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
MultiDev
  • 10,389
  • 24
  • 81
  • 148

1 Answers1

29

I think that you can try with relative protocol caller.

<link rel="stylesheet" href="//www.example.com/style.css">
                    ---------^^

if your users visit your web in http, it loads http, and if the user visit under https it loads https.

Marcos Pérez Gude
  • 21,869
  • 4
  • 38
  • 69
  • so there is no htaccess solution to this? I never use absolute urls on anything – Jaxx0rr Aug 14 '16 at 12:20
  • I think this doesn't have anything to do with htaccess – Marcos Pérez Gude Aug 16 '16 at 06:49
  • 1
    RewriteCond %{HTTP_HOST} =blabla.com RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] – Jaxx0rr Aug 20 '16 at 16:33
  • That doesn't solve the problem of the request, that only forces to access the webpage by https, but if server doesn't have an SSL certificate this is not a solution. My answer is reffered to the request of external resources, and it's the solution for the problem. – Marcos Pérez Gude Aug 21 '16 at 13:58
  • 1
    The problem of this workaround is sometime we need to use third party css and not supposed to change it. I got these: `Blocked loading mixed active content “http://jsfiddle.net/font/medium/BlackTie-Medium-webfont.woff2?v=1.0.0”`, `Blocked loading mixed active content “http://fonts.gstatic.com/s/inconsolata/v16/BjAYBlHtW3CJxDcjzrnZCI4P5ICox8Kq3LLUNMylGO4.woff2”`, `Blocked loading mixed active content “http://jsfiddle.net/font/solid/BlackTie-Solid-webfont.woff2?v=1.0.0”`. In fact the browser should handle the header. – zipper Dec 24 '17 at 02:43
  • 1
    htaccess cannot provide a workaround because the browser not loading mixed content means a request is never sent to the server, so the server never gets to respond nor process a htaccess redirect – Vince K Feb 21 '19 at 03:13