Use .htaccess to redirect HTTP to HTTPs

后端 未结 17 1556
刺人心
刺人心 2020-12-02 05:51

Please, don\'t recommend me the long and very detailed thread with more than 173 upvotes. It didn\'t work for me. I have also tried many others (1, 2, 3, 4). They all give m

17条回答
  •  自闭症患者
    2020-12-02 06:17

    For your information, it really depends on your hosting provider.

    In my case (Infomaniak), nothing above actually worked and I got infinite redirect loop.

    The right way to do this is actually explained in their support site:

    RewriteEngine on
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule (.*) https://your-domain.com/$1 [R=301,L]
    

    So, always check with your hosting provider. Hopefully they have an article explaining how to do this. Otherwise, just ask the support.

提交回复
热议问题