After moving the shop to HTTPS, product images and CSS stylesheets stopped loading in Chrome. The console showed hundreds of Mixed Content errors. The shop looked broken. Fix time: 1 hour.
Symptoms
- After HTTPS migration: no CSS styles and missing product images
- Browser console:
Mixed Content: The page was loaded over HTTPS but requested an insecure resource over HTTP - Media URLs in the database contain
http://instead ofhttps://
Solution
bin/magento config:set web/unsecure/base_url https://shop.com/ bin/magento config:set web/secure/base_url https://shop.com/ bin/magento config:set web/secure/use_in_frontend 1 bin/magento config:set web/secure/use_in_adminhtml 1
UPDATE core_config_data SET value = REPLACE(value, 'http://shop.com', 'https://shop.com') WHERE value LIKE '%http://shop.com%';
bin/magento cache:flush bin/magento setup:static-content:deploy -f
Takeaways
HTTPS migration requires updating URLs in the database, Magento configuration and checking redirects. Nginx should automatically redirect HTTP to HTTPS via return 301 https://....
