With only one CloudFront, you probably won't be able to accomplish what you are trying to do.
So, create a CloudFront distribution for www.example.com and a CloudFront distribution for example.com.
In the case of the domain www.example.com, I think you can solve this problem by setting up the S3 content to redirect to example.com.
The following StackOverFlow answers may be helpful.
Sounds like you’re trying to host a domain and subdomain on the same cloud front distro.
This is straightforward and doesn’t need to be complicated. Please follow the steps mentioned here https://repost.aws/knowledge-center/multiple-domains-https-cloudfront
You don’t need to copy dns to google. You host your dns records where ever the domain name servers are hosted.
ok, I followed the instructions on Stackoverflow and creates a new bucket for www and also created a new distribution for it. I am confused about the last step described in the post:
- Configure DNS by setting A records for www.example.com and example.com to point to corresponding CloudFront distributions.
I am already using name servers from the Hosted Zone for example.com So do I also need to create a new hosted zone for www and then copy the new nameservers to the domain name provider? Some clarification here will be helpful.
Or I do not need to use Route 53 and I can simply point A records to the Cloudfront URL? A records only take IP address and not a URL, so that was also confusing.
- Accepted Answerasked 2 years ago
- Why isn't my domain record in Route 53 that points to an Amazon S3 bucket or static website resolving?AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 4 months ago
- AWS OFFICIALUpdated 7 months ago
- EXPERTpublished 2 months ago