images - Mixed content warnings after changing site adress from HTTP to HTTPS

admin2025-06-04  2

I changed my site address from HTTP to HTTPS by simply changing the URL in Settings -> General (Wordpress address and Website address.) Absolutely no issue in the admin area, anything works fine.

What happens in the public facing portion of the website: there's a lot of "mixed content", so that Firefox complains the website isn't secure. I noticed (view source) almost any image that I have uploaded to the media gallery still is "rendered" with HTTP instead of HTTPS.

What can I do to serve the images, fonts, etc. with an HTTPS URL?

[UPDATE] I found a couple of issues can be fixed by editing two theme files with hardcoded "http://". Problem is with the images, if you don't want to alter the database there's apparently no solution

I changed my site address from HTTP to HTTPS by simply changing the URL in Settings -> General (Wordpress address and Website address.) Absolutely no issue in the admin area, anything works fine.

What happens in the public facing portion of the website: there's a lot of "mixed content", so that Firefox complains the website isn't secure. I noticed (view source) almost any image that I have uploaded to the media gallery still is "rendered" with HTTP instead of HTTPS.

What can I do to serve the images, fonts, etc. with an HTTPS URL?

[UPDATE] I found a couple of issues can be fixed by editing two theme files with hardcoded "http://". Problem is with the images, if you don't want to alter the database there's apparently no solution

Share Improve this question edited Apr 5, 2017 at 7:01 3000 asked Apr 4, 2017 at 15:35 30003000 1851 gold badge1 silver badge8 bronze badges 0
Add a comment  | 

5 Answers 5

Reset to default 8

This is happening because WordPress saves URLs in content absolutely by default (meaning that it's actually got your urls saved as http://example in the database). So to fix this you'll want to run a search and replace in your database to fix those errors.

I like to use the plugin Better Search Replace because it has a nice feature to let you try out your search/replace as a dry run to test. There are lots of other search/replace methods, and you could also make the changes in PhpMyAdmin, but I'll just put instructions for using the Better Search Replace plugin.

Assuming you are using Better Search Replace:

  1. BACK UP YOUR DATABASE! Always always always. Use whatever tool you want to do this (UpdraftPlus, or dump (NOT DROP) it from PhpMyAdmin or straight from MySQL are all options).
  2. Head to tools > Better Search Replace
  3. Add the non SSL version of your website to the search field http (eg. http://example) and the SSL version of your website to the replace field
  4. Select the tables you want to update. Most likely all you'll need is the wp_posts and wp_postmeta table but you can add them all if you like. Just know that it could take longer and time out depending on your server specs.
  5. Do a dry run to make sure that it works
  6. If it works, then uncheck the dry run option and run it for real.
  7. Check your website to verify the errors have been fixed. If they have, awesome!

Note: Any time you search/replace there's a chance you could cause massive problems to your website. Hence step one, back up your website. If something goes wrong, you have a way to restore your data.

You will have to need to redirect all your traffics from HTTP to HTTPS. A rewrite rule can do this for you. Use this code instead of WordPress's original rewrite rule (if you are not using cache) in your .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

There are plugins that can do this for you too, such as Easy HTTPS Rediction.

I used Better Search Replace and Really Simple SSL and the winner is:

Really Simple SSL

Just do this:

  1. Install it
  2. Activate it
  3. Allow SSL

Done

It also fixed all the problems with image redirection

Install this plugin: https://wordpress/plugins/http-https-remover/

Despite the name - HTTP / HTTPS Remover - the latest version will force all http to https, and your mixed content warnings will be gone.

I just moved my company site to the secure only version last Friday. I used the Really Simple SSL Plugin and then added a 301 redirect into my .htaccess file.

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Don't forget to also verify the HTTPS version of your site in Search Console / Webmaster Tools

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749009940a315584.html

最新回复(0)