How to Redirect website behind AWS Application Load Balancer
- Verify Apache / nginx logs in EC2 Instance for Live / Public IP addresses.
- If Live / Public IP address present in EC2 Instances logs, it means X-FORWARD-FOR working as expected.
- Now create a .htaccess file in webroot of the application
- Enable mod_rewrite in apache and put below re-write condition in newly created .htaccess
Rewrite condition
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} ^http$
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]