在使用mod_rewrite的Apache .htaccess文件中,是否可以强制www AND force https用于域?

时间:2010-03-09 12:37:26

标签: apache ssl https rewrite

RewriteCond %{HTTP_HOST} !^www.example.co.uk$ [NC] 
RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R=301,QSA,L] 

那是www的,但我无法弄清楚如何强制https?

1 个答案:

答案 0 :(得分:1)

使用SERVER_PROTOCOL变量:

RewriteCond ${SERVER_PROTOCOL} !^https [NC]