htaccess redirect to https://www

前端 未结 14 2262
夕颜
夕颜 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 11:49

    If you are on CloudFlare, make sure you use something like this.

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

    This will save you from the redirect loop and will redirect your site to SSL safely.

    P.S. It is a good idea to if check the mod_rewrite.c!

提交回复
热议问题