- Mais recentes
- Mais votos
- Mais comentários
(As per RFC 2606, I will use example.com instead of domain.com here.)
You cannot use an ALIAS record as a redirect. That isn't how ALIAS records work. It's mentioned in the ALIAS record docs:
When Route 53 receives a DNS query for an alias record, Route 53 responds with the applicable value for that resource:
...
Another Route 53 record in the same hosted zone – Route 53 responds as if the query is for the record that is referenced by the alias record.
Route 53 it respond "as if the query is for the record that is referenced by the alias record."
In this case, if you set up www.example.com as an ALIAS record to example.com, and example.com is an ALIAS record to the CloudFront distribution, Route 53 will respond to a request for www.example.com with the IP addresses of the CloudFront distribution - the same results as it returns for example.com.
However, if use the following configuration:
- Include both www.example.com and example.com in "Alternate domain names"
- Create a example.com as an ALIAS A record to the CloudFront Distribution domain name
- Create www.example.com as an ALIAS A record to example.com
- Ensure that your TLS certificate includes both www.example.com and example.com
Then you can visit www.example.com and your CloudFront distribution will be served without error.
However, again, it will not be a redirect. That is, the browser will still show www.example.com, not example.com. For that you need to use an S3 website endpoint (as it seems like you have already done), or an edge function, as outlined in this article.
However, again, it will not be a redirect. That is, the browser will still show www.example.com, not example.com yes i've tried that approach and noticed it. In fact the browser will treat www.example.com as an entirely different website which just has an identical content to example.com. This approach is also very bad for SEO. Thank you for your explanation about alias records. I'll accept it as the answer
Conteúdo relevante
- AWS OFICIALAtualizada há um ano
- AWS OFICIALAtualizada há 2 anos
- AWS OFICIALAtualizada há 10 meses
You must add all alternative domain names you intend to use for the Cloudfront distribution before adding the A/AAAA ALIAS in Route53.
I use non-www hostnames for my Cloudfront distributions and then have the S3 bucket static website configured for the www hostname to redirect to the non-www hostname. You would configure there A/AAAA record for the S3 bucket to point to s3-website-us-east-1.amazonaws.com if the bucket is in us-east-1 region, you would have to check for other regions. then you'd create the ALIAS entry pointing to the Cloudfront distribution