简体   繁体   中英

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. I deleted my .htaccess file and deleted every redirect I had in the control panel. Still not working. Neither my webhost support or CloudFlare support can help. This is my page rule setup as CloudFlare support told me to set it:

URL pattern: http:// .kohlercoding.dk/ setting: always use https

If you can edit the .htaccess file try this:

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. That means I have to have a verified certificate on my webhost which I didn't. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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