How can I redirect one domain to another in Route 53?
Last updated: 2022-07-13
I want to redirect my client from one domain to another domain in Amazon Route 53. How can I do this?
There are three common scenarios for configuring domain redirection:
1. Redirecting from one domain to another domain.
For example: apex domain (example.com) to domain (example.net) or subdomain
Subdomain (www.example.com) to domain (example.net)
2. Redirecting a domain from HTTP to HTTPS.
For example: (http://example.com) to (https://example.com)
3. Redirecting to a different URI path (path forwarding).
For example: example.com, example.com/<path>, www.example.com
www.example.com/<path> to example.com/<newpath>,
Based on your use case and configuration, see the resolution sections below. Be sure to consider the pricing for solutions that use multiple services.
Redirect using Route 53 DNS alias records
- example.com alias example.cloudfront.net
- www.example.com alias example.cloudfront.net
If you're using an HTTPS endpoint, then confirm that the DNS target supports an alternate domain name. For example, if you're using Amazon CloudFront, see Using custom URLs by adding alternate domain names (CNAMEs).
Redirect using a Canonical Name Record (CNAME)
Create a CNAME record in your Route 53 hosted zone to configure DNS redirection to map a non-apex domain to another domain. For example:
- www.example.com CNAME anysubdomain.example.com or www.example.net
- www.example.com CNAME example.com or example.net
Consider the following when redirecting using a CNAME:
- This method can't be used for an apex domain redirect.
- If you're using an HTTPS endpoint, then confirm that the DNS target supports an alternate domain name. If you're using CloudFront, see Using custom URLs by adding alternate domain names (CNAMEs).
- If you're pointing one domain to another using a CNAME, you might need additional configurations on the target endpoint application web server to accept the redirected domain request. This doesn't apply if you're using CloudFront or Amazon Simple Storage Service (Amazon S3).
Redirect using Route 53 and Amazon S3
Use Route 53 with an S3 website to redirect one domain to another domain through an HTTP redirect. For more information, see Is there a way to redirect an apex domain to another domain using Amazon S3 and Amazon Route 53?
Amazon S3 static web hosting supports only the HTTP protocol. You must use a CloudFront distribution for redirection from HTTP to HTTPS. For more information, see How do I use CloudFront to serve HTTPS requests for my Amazon S3 bucket?
Redirect using an Application Load Balancer
An Application Load Balancer can be used to redirect one domain to another through an HTTP redirect. Use this method if you want to include path forwarding. If you have a domain that points to an Application Load Balancer, it's a best practice to configure redirection using the Application Load Balancer.
For more information, see How can I redirect one domain to another domain using an Application Load Balancer?