1

I installed a new version of wordpress on a server web running under https.

I changed the two siteurl and home options value to my https://mysiteweb.com

I added the following value into my wp-config.php

define( 'WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/' );
define( 'WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/' );

define( 'WP_CONTENT_DIR', dirname(__FILE__) . '/wp-content' );
define( 'WP_CONTENT_URL',   'https://mysiteweb.com/wp-content' );

define( 'WP_PLUGIN_DIR', dirname(__FILE__) . '/wp-content/mydir/plugins' );
define( 'WP_PLUGIN_URL', 'https://mysiteweb.com/wp-content/mydir/plugins' );

Bu I still the same error for all css and javascript file loading:

Mixed Content: The page at 'https://mysiteweb.com/' was loaded over HTTPS, but requested an insecure script 'http://mysiteweb.com/wp-includes/js/wp-emoji-release.min.js?ver=5.4.2'. This request has been blocked; the content must be served over HTTPS.
0

3 Answers 3

5

I solved my problem by editing wp-config.php:

$_SERVER['HTTPS']='on';
Sign up to request clarification or add additional context in comments.

1 Comment

This helped me, I was migrated an existing website app service with wordpress. I am surprised that I need to put such essential setting in the configuration. Locally and on the original server it works without this setting.
0

Press CRTL + U and check your page source for HTTP, after you found where it's loading the HTTP replace it with HTTPS, usualy the problem is some image or logo not properly loaded / hard coded into HTTP.

Also why did you use $_SERVER['HTTP_HOST'] ? rather then just writing your domain. Possible problem that I see you don't need to use the backslash on last part of the domain.

define( 'WP_SITEURL', 'https://example.com'  );
define( 'WP_HOME', 'https://example.com' );

And you don't need to use the other part's which you defined.

1 Comment

I replaced WP_SITEURL and WP_HOME with https and I still have the same problem, It's a new wordpress version I touched to anything yet.
0

I explored the file wp-config.php and found:

if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false) {
        $_SERVER['HTTPS'] = 'on';
}

Solution 1:

set X-Forwarded-Proto as https. If you are using nginx the configuration can be:

server {
    listen 443 ssl;
    server_name myblog.com;

    location / {
        proxy_pass http://wordpress/;
        proxy_redirect http://wordpress/ https://myblog.com/;
        proxy_set_header Host myblog.com;
        proxy_set_header X-Forwarded-Proto https;
    }
}

Solution 2:

set directly $_SERVER['HTTPS']='on'; to the file wp-config.php.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.