I set Secure Base URL to https://magento22.local , did setup:upgrade settings But now it tries to load all static content through http and chrome gives error "mixed content", so no styles or script are loaded.

result I tried clearing everything - cache, static files folder, reloading server, enabling production mode - nothing helps.

What's the problem? Why Magento doesn't use HTTPS URLs?

"Use Secure URLs on Storefront" setting doesn't change anything

4 Answers 4


The problem was that I didn't finished local SSL setup with adding this to my whosts file:

<VirtualHost *:443>


SSLEngine on

SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key

<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars

Because of that magento's isSecure() method was returning false (it checks values in $_SERVER array - HTTPS and PORT - not just checks the requested URL) and Magento used settings from the Unsecure section.


here you go:

bin/magento setup:store-config:set --base-url="https://domain.com/" --base-url-secure="https://domain.com/" --use-secure=1 --use-secure-admin=1 bin/magento cache:flush

change domain.com to your domain.


Did you install ssl for localhost server?

Try to add it:

sudo nano /etc/apache2/apache2.conf

Modify section:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted

to this

<Directory /var/www/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

After that, run command

sudo a2enmod ssl

sudo a2ensite default-ssl

sudo a2enmod rewrite

sudo service apache2 restart
  • Looks like the problem with certificate. Magento's isSecure method returns false when I access site with HTTPS
    – Audiophile
    Commented Jan 23, 2019 at 14:46

Try to execute below command and try it in magento root directory.

$ rm -rf pub/static/frontend/* pub/static/adminhtml/* var/cache/ generated/* var/page_cache/ var/view_preprocessed/ var/composer_home $ php -dmemory_limit=6G bin/magento setup:static-content:deploy -f

In above code $ rm -rf command delete your pub/static & var/cache.

For more reference you can check This link

Edit :

Make sure your configuration looks like this:

Stores > Configuration > General > Web:

Base URLs:

Base URLs (Secure):

  • Secure Base URL: https://www.yourdomain.com/
  • Secure Base Link URL: {{secure_base_url}}
  • Use Secure URLs on Storefront: Yes
  • Use Secure URLs in Admin: Yes
  • Enable HTTP Strict Transport Security (HSTS): Yes
  • Upgrade Insecure Requests: Yes

Edit :

It might be a chance Static content signing problem because

Static content signing is a Magento feature that allows you to invalidate the browser cache for static resources. Magento accomplishes this by adding a deployment version to the URL of static files .

The following is an example of a URL signed with a version:


When you run the command setup:static-content:deploy to deploy static content, Magento automatically changes the deployment version. This changes the URL of the static files and forces the browser to load the new version of the files.

For that you need to change the setting of Static content signing under

Stores > System > Configuration > Advanced > Developer > Static Files Settings.

Set to NO

And then run below command.

$ rm -rf pub/static/frontend/* pub/static/adminhtml/* var/cache/ generated/* var/page_cache/ var/view_preprocessed/ var/composer_home $ php -dmemory_limit=6G bin/magento setup:static-content:deploy -f

Then check it might be work.

For more reference check DevDocs links

I hope it helps!

  • Magento still tries to load css and js files with http
    – Audiophile
    Commented Jan 23, 2019 at 13:52
  • Check my updated answer. Commented Jan 23, 2019 at 13:56
  • And you not passed correct URL in Base URLs: you misses to pass s, you hav to pass http to https Commented Jan 23, 2019 at 13:58
  • Base URL's should be http://, https is only for secure.
    – Audiophile
    Commented Jan 23, 2019 at 14:05
  • @Audiophile check my updated answer. Commented Jan 24, 2019 at 5:22

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.