2017-09-23 28 views
-1

好的我检查了所有其他类似的答案,但多亏downvote没有理由的人没有实际的回应。WordPress的混合内容请求一个不安全的XMLHttpRequest端点

我使用WordPress的,我有一个混合内容与网站https://oujdaportail.net/

它产生这样的错误:

Mixed Content: The page at ' https://oujdaportail.net/ ' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ' http://oujdaportail.net/ '. This request has been blocked; the content must be served over HTTPS.

Chrome的调试控制台已经完全没用!它在没有任何内容的源代码的第一行检测到错误。

我不知道我该如何解决这个问题......我需要帮助来捕获此问题的来源。

+0

如果您的问题得到了downvoted,那么它们不符合该网站的指导原则。请查看[帮助中心](https://stackoverflow.com/help/asking)Stack Overflow策略可降低不符合网站指南的问题。如果您没有提供足够的信息,我们无法提供帮助 - 我们不介意读者!我们不知道你的代码或者是什么导致你的错误。您需要自己调试问题 - Chrome调试控制台不是调试的开始和结束。 – FluffyKitten

回答

0

终于!我会成为别人的英雄......

经过数小时的努力,结果发现wp_headwp_footer负责生成未知的HTTP请求。而要解决这个问题,我只需要创建一个自定义的wp_head和wp_footer函数,就像这样:

/** 
* Wrapper for wp_head() which manages SSL 
* 
* @uses wp_head() 
* @param bool $ssl 
* @return void 
*/ 
function custom_wp_head() { 
    // Capture wp_head output with buffering 
    ob_start(); 
    wp_head(); 
    $wp_head = ob_get_contents(); 
    ob_end_clean(); 

    // Replace plain protocols 
    $wp_head = preg_replace('/(["\'])http:\/\//', '\1https://', $wp_head); 

    // Output 
    echo $wp_head; 
} 

function custom_wp_footer() { 
    // Capture wp_head output with buffering 
    ob_start(); 
    wp_footer(); 
    $wp_footer = ob_get_contents(); 
    ob_end_clean(); 

    // Replace plain protocols 
    $wp_footer = preg_replace('/(["\'])http:\/\//', '\1https://', $wp_footer); 

    // Output 
    echo $wp_footer; 
} 
相关问题