Search code examples
amazon-web-servicesamazon-s3amazon-cloudfrontweb-hosting

Route www subdomain traffic to https domain cloudfront


I have a domain say example.com paired with Cloudfront and S3 to host a static website. The problem is while https://example.com and http://example.com are working fine but www.example.com is not working.

How can I add the config to route the traffic correctly from www sub-domin also? Thanks!


Solution

  • Follow the below steps to satisfy your requirement:

    • In N-Virginia region Open ACM (Certificates Manager), request a certificate for test.example.com, and add www.test.example.com as an alternate domain (@ Add another name to this certificate)
    • Open created certificate and click on Create Records in Route53, then wait for it to succeed.

    Create SSL Certificate for Sub Domains

    • Open your Cloudfront Distribution
    • Click on Edit Under General tab > Settings
    • Make sure you add two required domains in alternate domain names.
    • Choose a newly created certificate under Custom SSL Certificate
    • Then save, and wait for it to Deploy
    • Then you can add route53 record for www.test.example.com domain
      • A Record
      • Choose the alias checkbox
      • Choose your CloudFront distribution

    Update Cloudfront Distribution