Force non-www and https via htaccess

前端 未结 3 1116
醉话见心
醉话见心 2020-12-14 08:53

I\'m trying to force a user to be redirected to the non-www website, and, force https.

I\'ve got this which sort of work, but doesn\'t force https, when http is ente

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 09:22

    Try this rule:

    RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
    RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
    

提交回复
热议问题