htaccess redirect to https://www

前端 未结 14 2267
夕颜
夕颜 2020-11-21 11:01

I have the following htaccess code:



RewriteEngine On
RewriteCond !{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{RE         


        
14条回答
  •  不要未来只要你来
    2020-11-21 12:00

    If you are using CloudFlare or a similar CDN you will get an infinite loop error with the %{HTTPS} solutions provided here. If you're a CloudFlare user you'll need to use this:

    RewriteEngine On
    RewriteCond %{HTTP:X-Forwarded-Proto} =http
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

提交回复
热议问题