I'm trying to setup the redirects such that all variations:
http://example.com, http://www.example.com, https://example.com
redirect to https://www.example.com
I've gone through several other posts and have it working except I'm noticing some weirdness in the redirects.
http://www.example.com -> 301 -> https://www.example.com Working as Intended
http://example.com -> 301 -> http://www.example.com -> 301 -> https://www.example.com
Scenario 1: Is there a way to skip the first 301?
https://example.com -> 301 -> http://www.example.com -> 301 -> https://www.example.com
Scenario 2: It actually redirects back to http first. Is there a way to skip the first 301?
Setup
S3
Two buckets:
- www.example.com which hosts the site
- example.com, which redirects to www.example.com with https protocol.
CloudFront
Two distributions:
Distribution one
- custom origin: www.example.com.s3-website-us-west-2.amazonaws.com
- alternate cname: www.example.com
- viewer protocol policy: Redirect HTTP to HTTPS
Distribution two
- custom origin: example.com.s3-website-us-west-2.amazonaws.com
- alternate cname: example.com
- viewer protocol policy: HTTP and HTTPS
Route 53
A and AAAA records for example.com and www.example.com each pointing to their respective Cloudfront distributions.