【问题标题】:Wordpress https css and js script not loaded,未加载 Wordpress https css 和 js 脚本,
【发布时间】:2020-11-08 07:14:09
【问题描述】:

我在 https 下运行的服务器 web 上安装了新版本的 wordpress。

我将两个 siteurl 和 home 选项值更改为我的 https://mysiteweb.com

我在 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' );

但是对于所有 css 和 javascript 文件加载,我仍然是同样的错误:

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.

【问题讨论】:

    标签: wordpress https mixed-content


    【解决方案1】:

    按 CRTL + U 并检查您的页面源是否为 HTTP,在找到加载 HTTP 的位置后将其替换为 HTTPS,通常问题是某些图像或徽标未正确加载/硬编码到 HTTP 中。

    还有你为什么使用 $_SERVER['HTTP_HOST'] ?而不是只写你的域名。 我看到您不需要在域的最后一部分使用反斜杠的可能问题。

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

    而且你不需要使用你定义的其他部分。

    【讨论】:

    • 我用 https 替换了 WP_SITEURL 和 WP_HOME,但我仍然遇到同样的问题,这是一个新的 wordpress 版本,我接触过任何东西。
    【解决方案2】:

    我通过编辑 wp-config.php 解决了我的问题:

    $_SERVER['HTTPS']='on';
    

    【讨论】:

      猜你喜欢
      • 2014-07-25
      • 2017-09-10
      • 2013-09-17
      • 2017-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-12
      相关资源
      最近更新 更多