I currently have this in place to redirect all http
traffic to https
.
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R=301,L]
The above is working OK.
Now I'm trying to add rewrite condition to force all https://www
traffic to https
without the www
.
Please note that this is an AWS Elastic Beanstalk running Apache behind Elastic Load Balancer
=============================
EDIT:
Working code:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !=https [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{SERVER_NAME} ^(www\.)?(.*)$ [NC]
RewriteRule ^/?(.*)$ https://%2/$1 [L,R=301]