Search code examples
amazon-s3amazon-cloudfront

Point non www domain to existing cloudfront distribution


I'm using AWS S3 and Cloudfront to host a website (e.g. www.company.com). I want to additionally have the the naked domain (without the www) to point to the same content. I initially created a redirect in DNS but https://company.com didn't work.

I can create an apex record for the naked domain in the DNS but can I point it to the same cloudfront CNAME used for the www.company.com or do I have to create a new S3 bucket and new cloudfront distribution?


Solution

  • S3 to CloudFront Distribution

    1. Create two CloudFront distributions
    2. Request for Certificates from AWS Certificates Manager
    3. Create CNAME with Route 53 and point the alias target to the respective distributions
    4. Create Origin in both distributions pointing to that S3 bucket

    Hope it helps.