简体   繁体   English

Web服务器不断重定向到HTTP

[英]Web server keeps redirecting to HTTP

I'm trying to use CloudFlare page rule to redirect to https but when I set it up it gives me the redirect loop and keeps changing back and fourth between http and https. 我正在尝试使用CloudFlare页面规则重定向到https,但是在设置它时,它给了我重定向循环,并不断在http和https之间来回切换。 I deleted my .htaccess file and deleted every redirect I had in the control panel. 我删除了.htaccess文件,并删除了控制面板中的每个重定向。 Still not working. 还是行不通。 Neither my webhost support or CloudFlare support can help. 我的网络主机支持或CloudFlare支持均无济于事。 This is my page rule setup as CloudFlare support told me to set it: 这是我的页面规则设置,因为CloudFlare支持人员告诉我进行设置:

URL pattern: http:// .kohlercoding.dk/ setting: always use https 网址格式:http:// .kohlercoding.dk /设置:始终使用https

If you can edit the .htaccess file try this: 如果您可以编辑.htaccess文件,请尝试以下操作:

RewriteCond %{HTTP_HOST} ^website.com [NC]
RewriteRule ^(.*)$ https://www.website.com/$1 [L,R=301]

RewriteCond %{HTTPS} =off
RewriteCond %{HTTP_HOST} ^www.website.com$
RewriteRule ^(.*)$ https://www.website.com/$1 [R=301,L]

I just found out the problem is that I had my SSL setting on "Full" on CloudFlare. 我刚刚发现问题是我在CloudFlare上将SSL设置设置为“ Full”。 That means I have to have a verified certificate on my webhost which I didn't. 这意味着我必须在我的Web主机上拥有经过验证的证书,而我没有。 That's why it didn't work. 这就是为什么它不起作用。 So changing it to "Flexible" fixed my problem. 因此,将其更改为“灵活”可以解决我的问题。 Or having a self-signed certificate on the webhost if they support it and, unlike UnoEuro, doesn't make you pay for HTTPS Protection. 或者,如果他们在Web主机上拥有自签名证书(如果他们支持),并且与UnoEuro不同,则不需要您为HTTPS保护付费。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM