强制使用 HTTPS

Avatar of Chris Coyier
Chris Coyier
RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

如果您在服务器前面有一个代理执行 TLS 终止

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}