0

I have searched almost everywhere on how to redirect with cloudfront. I created an s3 bucket for static website hosting and even used their redirect there BUT because i am not serving whole website via cloudfront, now cloudfront does not follow that redirect rule.

How can i make cloudfront redirect non www to www?

uberrebu
  • 503
  • 6
  • 17
  • 36
  • Duplicate question http://stackoverflow.com/questions/28675620/cloudfront-redirect-www-to-naked-domain-with-ssl . See also https://www.pbxdom.com/how-redirect-non-www-to-www-with-amazon-cloud-front-route-53-and-s3 – Tim Jul 24 '16 at 20:01
  • @Tim The [so] question you linked is the reverse of this one. – Michael Hampton Jul 24 '16 at 20:09
  • 1
    Concept should be similar shouldn't it? – Tim Jul 24 '16 at 20:36
  • @Tim i tried `https://www.pbxdom.com/how-redirect-non-www-to-www-with-amazon-cloud-front-route-53-and-s3` already and did not work. How will DNS route www if i only have non-www record in route53? so that did not work..and www to non-www is a little different – uberrebu Jul 25 '16 at 02:40
  • If you don't have a www record in DNS I can't see how it could work. – Tim Jul 25 '16 at 03:20
  • well the link has no record for www is what am saying – uberrebu Jul 25 '16 at 03:38

1 Answers1

1

I ended finding out that i will need 2 S3 buckets one for the redirect and the other for my main site and host the main one behind cloudfront, also in route53 i route the www to cloudfront and the non-www to the S3 buckt that redirects to the www.

And that was it. It took me lots of digging to figure out i needed to make 2 S3 buckets. So for anyone else going through this, you need 2 S3 buckets, the other will be just for redirect and doesn't even have to have a single file in it, because it won't serve anything other than redirect

uberrebu
  • 503
  • 6
  • 17
  • 36