Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29245

Redirect all www and http ==>> non www https on AWS Elastic Beanstalk with Load Balancer

$
0
0

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]

Viewing all articles
Browse latest Browse all 29245

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>