Search code examples
dnssubdomainamazon-cloudfrontamazon-route53

How to forward domain to Cloudfront URL without showing target URL in browser?


I have a domain which I want to redirect to a AWS cloud front URL.

If I only add a redirect at my domain provider then browser shows the cloud front URL in address bar which looks ugly.

I can create a CNAME record with the cloud front URL to a sub-domain, but not directly to the domain, but I do not want user to type the complete sub-domain name.

I tried adding a combination of (1)a redirect from domain to the sub-domain and (2) a CNAME record from that sub-domain to the cloud-front URL. But, of course, I get "too many redirects".

What is the correct solution for this? Will any Route53 service fix this problem?


Solution

  • I changed the name server on my DNS to AWS route-53 ones and then added a record to the Alias pointing to my cloud-front distribution. In Cloud-front, I had to set my domain name as the Cname.

    An alternate solution, and effectively another way to create virtual record, could have been as discussed here in "The Solution" section. Unfortunately my domain registrar(1&1) doesn't support this feature.

    [Edit 06/27] I tried CloudFlare's CNAME flattening feature and that works as well.