- Newest
- Most votes
- Most comments
Hello.
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.
https://stackoverflow.com/questions/28675620/cloudfront-redirect-www-to-naked-domain-with-ssl
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.
I hope there was an option to accept multiple answers of split my acceptance between two answers. Both your and Riku's tips helped me solve my problem.
Unfortunately not. However I’m glad myself and Riku have helped you solve your issues here.
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.
Relevant content
- Accepted Answerasked 3 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
For Route53, you can set alias records. Create alias records like example.com and www.example.com. https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-choosing-alias-non-alias.html https://repost.aws/knowledge-center/route-53-create-alias-records
Also, there is no need to create a new hosted zone for www. Create www.example.com as a subdomain within the example.com hosted zone. Note that alias records are not available if your domain is not managed by Route53.
OK, so I can just create a subdomain within the original hosted zone and that will simply work? or will I also need to create a alias record? I have created Alias pointing to the budket, not to the URLs are you mentioned. Is that right?
Create the state in the image below. Just create a subdomain within a hosted zone of example.com. I think you need to create an alias record for CloudFront.
Ok, so I have done this exact same configuration. Now http://example.com http://www.example.com both are redirecting to https://example.com
But https://www.examples.com is not redirecting.