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?

6
  • Duplicate question stackoverflow.com/questions/28675620/… . See also pbxdom.com/…
    – Tim
    Jul 24, 2016 at 20:01
  • @Tim The Stack Overflow question you linked is the reverse of this one. Jul 24, 2016 at 20:09
  • 1
    Concept should be similar shouldn't it?
    – Tim
    Jul 24, 2016 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, 2016 at 2:40
  • If you don't have a www record in DNS I can't see how it could work.
    – Tim
    Jul 25, 2016 at 3:20

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .