且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用htaccess一起强制SSL和WWW

更新时间:2023-09-19 10:35:34

通过其他提供的答案组合来强制执行https和www。

Forcing https and www is done by a combination of other provided answers.

这似乎可行:

RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

RewriteCond %{ENV:HTTPS} on [NC]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]