- Newest
- Most votes
- Most comments
Hello nxr. To redirect your www subdomain to your root domain using AWS Amplify and Route 53, we'll need to make some adjustments to your current setup. Here's a step-by-step guide to accomplish this task:
Update Route 53 DNS Records
- Log in to the AWS Management Console and navigate to Route 53.
- Select your hosted zone for "my.tld".
- Delete the existing CNAME record for "www.my.tld".
Create a new A record for "www.my.tld" and set it as an alias to your CloudFront distribution (abcdefg99.cloudfront.net).
Configure CloudFront Distribution
- Go to the CloudFront console.
- Select your distribution (abcdefg99).
- Under the "General" tab, click "Edit".
- In the "Alternate Domain Names (CNAMEs)" field, add both "my.tld" and "www.my.tld".
- Save the changes.
Set Up Redirect in Amplify
- Navigate to the AWS Amplify console.
- Select your app and go to "Rewrites and redirects".
- Add a new rule with the following settings: Source address: https://www.my.tld Target address: https://my.tld Type: 301 (Permanent redirect)
- Save the changes.
Update Amplify Custom Domain Settings
- In the Amplify console, go to "Domain management".
- Add "www.my.tld" as a custom domain if it's not already there.
- Verify that both "my.tld" and "www.my.tld" are listed and properly configured.
Test the Redirect
- Clear your browser cache to ensure you're not seeing cached results.
- Try accessing "www.my.tld" in your browser. Verify that it redirects to "my.tld".
Monitor and Troubleshoot
- Use browser developer tools to check the redirect status code (should be 301).
- If the redirect doesn't work immediately, allow some time for DNS propagation (up to 48 hours in some cases).
- Check CloudFront and Amplify logs for any errors or issues.
By following these steps, you should be able to successfully redirect your www subdomain to your root domain using AWS Amplify and Route 53. This setup ensures that users typing "www.my.tld" will be redirected to "my.tld", providing a consistent experience for your website visitors.
Remember to test thoroughly in a non-production environment before applying changes to your live site. If you encounter any issues or need further assistance, consider consulting AWS support or the official documentation for the most up-to-date information and best practices.
Additional Resources:
https://docs.aws.amazon.com/AmazonS3/latest/userguide/website-hosting-custom-domain-walkthrough.html
https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/getting-started-s3.html
https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteEndpoints.html
Best of luck and thank you for using AWS!
Brian
Relevant content
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 10 months ago

You can try this: https://docs.aws.amazon.com/amplify/latest/userguide/to-add-a-custom-domain-managed-by-google-domains.html