Forcing SSL and WWW using .htaccess

前端 未结 7 814
野性不改
野性不改 2020-12-13 00:59

I would like to know if this code in .htaccess for forcing SSL and WWW in URL is correct, because with another codes I usually get redirect loop, e.g. Rew

7条回答
  •  不知归路
    2020-12-13 01:14

    That's a bit simpler.

    RewriteEngine On
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
    RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
    

提交回复
热议问题