RewriteEngine On # If we receive a forwarded http request from a proxy... RewriteCond %{HTTP:X-Forwarded-Proto} =http [OR] # ...or just a plain old http request directly from the client RewriteCond %{HTTP:X-Forwarded-Proto} ="" RewriteCond %{HTTPS} !=on # Redirect to https version RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]