1

I have my-domain.com. I want requests to the www subdomain to redirect to the root, and all requests to redirect to https.

I have 2 S3 buckets - my-domain.com and www.my-domain.com (empty bucket configured to redirect to my-domain.com)

I've set up a Cloudfront distro in front of my-domain.com for https.

For DNS, I have an A record for my-domain.com which is an 'alias' record pointing to the cloudfront distro. I have another A record for www.my-domain.com which is an 'alias' record pointing to the empty www.my-domain.com S3 redirection bucket

This results in the following redirects:

http://my-domain.com -> https://my-domain.com

http://www.my-domain.com -> https://my-domain.com

However a request to https://www.my-domain.com does not redirect. I'm presuming this is because there is no https listener for the S3 redirection bucket. So my question is, is there a better way to do this? I really don't want to have to set up another cloudfront distro just to have this functionality but it feels to me broken if https://www does not redirect correctly.

Thanks in advance,

rix
  • 10,104
  • 14
  • 65
  • 92

1 Answers1

0

@rix,

Perhaps this might be what you are looking for. [AWS S3 website+cloudfront root domain redirect issues] (Cloudfront redirect www to naked domain with ssl)

jningthou
  • 852
  • 7
  • 10
  • I know that's exactly the same question, it's just a bit older and things tend to change very quickly with AWS and this whole 2xS3 buckets + 2xcloudfront distros is getting a little bit silly in my opinion. I think I may just alias the www as im not fussed about SEO for this site and this architecture seems simply wrong. It's a pity as S3 hosting is fantastic.. – rix Oct 14 '18 at 18:51