Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在https://中设置默认Wordpress并将其重定向到http://并在Cloudflare中将http://转发到https://中_Php_Wordpress_.htaccess_Redirect_Ssl - Fatal编程技术网

Php 在https://中设置默认Wordpress并将其重定向到http://并在Cloudflare中将http://转发到https://中

Php 在https://中设置默认Wordpress并将其重定向到http://并在Cloudflare中将http://转发到https://中,php,wordpress,.htaccess,redirect,ssl,Php,Wordpress,.htaccess,Redirect,Ssl,早些时候,我已将默认Wordpress安装设置为http://并在Cloudflare中将其重定向为使用Https SSL,但在浏览器上出现了多个混合内容错误[stating对Https的请求是http] 所以,fresh将我的整个wordpress安装为使用https://但是我在一个没有安装SSL证书的共享服务器上,所以现在我的整个站点重定向到https://并显示[server not found error] 我需要将我的wordpress保持在https://格式,以便使用站点地图和其

早些时候,我已将默认Wordpress安装设置为http://并在Cloudflare中将其重定向为使用Https SSL,但在浏览器上出现了多个混合内容错误[stating对Https的请求是http]

  • 所以,fresh将我的整个wordpress安装为使用https://但是我在一个没有安装SSL证书的共享服务器上,所以现在我的整个站点重定向到https://并显示[server not found error]

  • 我需要将我的wordpress保持在https://格式,以便使用站点地图和其他插件只访问https://而不发生冲突

  • -那么,我是否需要将所有https://重新定向到.htaccess文件中的http://中,然后将http://重定向到cloudflare中以使用https://,而我的默认Wordpress安装为https://

    • 在.htaccess中使用了多个规则,但无效。请告诉我将所有http://重定向到https的确切规则://

      重写cond%{SERVER_PORT}^443$ 重写规则^(.*)${HTTP_HOST}/$1[R=301,L]

      RewriteCond %{HTTPS} on
      RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
      
      
      #RewriteEngine On
      RewriteCond %{SERVER_PORT} 443
      RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
      

    如果您的服务器不在443端口上侦听,您不能以这种方式重定向它们

    如果只是一个无效的证书,重定向时总会出现“无效证书”错误。但它应该是这样工作的:

    RewriteEngine On
    RewriteCond %{HTTPS} on
    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
    
    您应该尝试获取有效的证书。
    这些都是免费开始的好方法。

    您解决了问题吗?也许您需要将其添加到wp-config.php中

    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
    $_SERVER['HTTPS']='on';
    
    它告诉您的wordpress虚拟机使用wordpress服务器上的(cloudflare)主机名。如果SSL是由cloudflare完成的,那么这可以工作,因为LoadBalance后面的流量是非SSL流量。但我根本不知道Cloudflare的详细信息;)


    另外,您需要将wordpress homeurl和siteurl设置为用户应该看到的https域。

    谢谢Kneecht。。但是不允许在我的共享服务器主机上安装Ssl:(有使用https的替代方案吗?您可以尝试以下操作:
    RewriteCond%{HTTP:CF Visitor}'scheme:“HTTP”RewriteRule^(.*)$https://www.domain.com/$1[L]
    有关详细信息,请参阅。但请注意,CloudFlare灵活的SSL从来都不安全,您只是“耍花招”用户。此规则有效,但https://不重定向或挂锁指向:(RewriteCond%{HTTP_HOST}^reviewsanswers\.com$[NC]RewriteRule^(.*)$[R=301,L]现在您只需重写reviewanswers.com,而不是www.reviewanswers.com。这就是您的JS/CSS未加载的原因。顺便说一下,您应该尝试加载CSS/JS,如
    //example.com/style.CSS