2

I'm moving my Drupal 7 website to https but I keep having issues with some images that gets loaded with full path, but with http://. For example the site logo and view images have http:// path. (Inside DB table file_amanged files are all saved with public:// path.) They are all files loaded through the Drupal UI.

How can I force all images to use https?

3 Answers 3

1

You need to use a module like Pathologic which will force protocol relative URLs for all assets.

https://www.drupal.org/project/pathologic

The public:// path is a stream wrapper, and has no effect on whether the browser sees http/https or not. Pathologic will fix all of this for you.

1
  • I've already installed pathologic and tried both 1. Protocol relative URL (//example.com/foo/bar) 2. Path relative to server root (/foo/bar) but none of them solved my issue.
    – Mbertin
    Commented Sep 22, 2017 at 13:22
1

I know this is an old post but I ran into this issue on several sites with a ton of content. I ended up adding a meta tag to my html.tpl for a quick fix

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

See https://developers.google.com/web/fundamentals/security/prevent-mixed-content/fixing-mixed-content

0

The only solution I've found so far is adding a mytheme_preprocess_html to replace all absolute:

Insecure content warning with D7 and SSL

3
  • Sounds like you may have some absolute URLs in your DB. A preprocess function can certainly sort that out if you don't want to fix and find them in the DB. Commented Sep 25, 2017 at 9:01
  • I've checked on file_managed table but there is no absolute URL there. I've cleared cache hundreds of times and still I got http instead https. I don't where else to look.
    – Mbertin
    Commented Sep 25, 2017 at 14:50
  • The only http content I can see is your favicon, which will be set via the variables table most likely. Commented Sep 25, 2017 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.