0

After switching my wordpress site to https the images fail to load on the website, but the images load fine when their URL is pasted directly into the browser.

This is what I did to perform the switch:

  1. Searched and replaced all instances of http://www.mydomain with https://www.mydomain using the WP DB Migrate plugin;

  2. Added redirection code at the top of the htaccess file to redirect http to https;

  3. Modified wp-config.php file to force wordpress admin to load as https;

  4. made the canonical URL https://mydomain in the General settings of wordpress.

When I go to the Media section of Wordpress (where the images are kept), most of them are not visible, but again, when the image URL is copied and pasted directly into the browser, they load fine -- and then they are visible on the webpage too (but only to me -- not to other users on other machines).

The SSL itself works fine, and there are no mixed content errors.

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
lavideo
  • 11
  • 1
  • Are there any redirect headers like 301 or 302 set, when you click on one of the images? To see what headers are set see: https://stackoverflow.com/questions/4423061/view-http-headers-in-google-chrome – Tom May 29 '19 at 17:20
  • Okay, so it doesn't seem like that there are any redirects, when accessing the image directly. – Tom May 29 '19 at 18:12
  • So what else might be going on, in your opinion? – lavideo May 29 '19 at 19:17
  • I noticed that the https redirect code wasn't in the htaccess file -- I have put it back in at the very top of the htaccess file -- does this make a difference to what you were looking for? – lavideo May 29 '19 at 19:31
  • Here are some things you should try: - Do you have .htaccess files in your media directories? If so, remove them, or adapt them to the https domain. - Deactivate any plugins that redirect to https. If none of the above work, migrate this question to wordpress.stackexchange.com – Tom May 29 '19 at 20:03
  • There are no SSL / HTTPS plugins and there is no htaccess file in the media folder. – lavideo May 29 '19 at 20:15
  • 1. Can you show your htaccess file? 2. Are you updated DB, and changed http to HTTPS? 3. Cleaned cache if you have it? 4. Try [Really Simple SSL plugin](https://wordpress.org/plugins/really-simple-ssl/) – Rimarx May 29 '19 at 20:15
  • 1
    I replaced all HTTP instances with HTTPS in the database. When I clear the cache and deactivate ALL plugins, the problem persists. The Really Simple SSL plugin does not solve the problem. – lavideo May 29 '19 at 20:30
  • 1
    Is this line in the htaccess file interfering with image loading? All plugins are disabled (including the one that prevents hotlinking): RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC] – lavideo May 29 '19 at 20:45

1 Answers1

1

I suspected it might be an anti-hotlinking code issue, so I deleted this line from the htaccess file:

RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC] 

Now, images load correctly.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
lavideo
  • 11
  • 1