Force HTTS redirect behind an AWS Elastic Load Balancer

If you want to force HTTPS for your site behind an AWS Elastic Load Balancer, place this in your .htaccess file, just after Rewrite Engine On:

    # Force HTTPS - Proto needed for AWS ELB
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteCond %{HTTP_USER_AGENT} !^ELB-HealthChecker
    RewriteRule ^.*$ https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s