Force HTTPS with mod_rewrite, including proxied SSL
The problem was the whitespace after the "!=":
Working version:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
tricky...