Redirect Not Working for www Subdomain on Amplify App

1

Hello AWS Support,

I’m hosting a single-page application using AWS Amplify at https://biodatagenerator.com, and I’ve added the www.biodatagenerator.com subdomain via Amplify’s Domain Management.

I want all traffic from www.biodatagenerator.com to redirect to biodatagenerator.com (non-www version). I’ve set up the following redirect rules in Amplify: [ { "source": "https://www.biodatagenerator.com", "status": "301", "target": "https://biodatagenerator.com" }, { "source": "/<*>", "status": "404-200", "target": "/index.html" }, { "source": "</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|jpeg|webp|txt|svg|woff|ttf|map|json|webmanifest)$)([^.]+$)/>", "status": "200", "target": "/index.html" } ]

And here is my dns records: Enter image description here

However: The www.biodatagenerator.com does not redirect to the root domain. Could you help me confirm: If my redirect rule is properly configured to handle www → non-www redirection at the domain level? Please let me know if any additional configuration is needed?

2 Answers
0

Thank you for your response.

I’ve already tried all the suggested methods, including:

  • Adding appropriate redirect rules in Amplify.
  • Deleting and re-adding the domain from the Amplify console.
  • Ensuring correct DNS entries in Route 53.

Despite this, the issue still persists. When I access https://www.biodatagenerator.com, it does not redirect to the root domain (https://biodatagenerator.com). Instead, the site loads directly on the www subdomain.

Could you please help verify if the redirect is being applied correctly at the domain or CloudFront layer, or if additional configuration is needed to enforce a proper 301 redirect from www to the root domain?

Appreciate your support on this.

Best regards, Ashish

answered 5 days ago
-1

Based on the information provided, it appears that your redirect rule for the www subdomain to the root domain is not working as expected. Here are a few things to check and consider:

  1. Domain Management in Amplify: Make sure you have included both the root domain (biodatagenerator.com) and the www subdomain (www.biodatagenerator.com) in your Amplify domain management settings. Sometimes, the root domain needs to be explicitly added for the redirection to work properly.

  2. Redirect Rule: Your current redirect rule looks correct for redirecting the www subdomain to the root domain. However, you might want to make it more generic to catch all paths:

    {
      "source": "https://www.biodatagenerator.com/<*>",
      "status": "301",
      "target": "https://biodatagenerator.com/<*>"
    }

    This will ensure that any path accessed via the www subdomain is properly redirected to the same path on the root domain.

  3. DNS Configuration: Your DNS records look correct, with CNAME records for both the www subdomain and the root domain pointing to Amplify. However, ensure that these records have fully propagated, which can take up to 48 hours in some cases.

  4. SSL/TLS Certificate: Verify that your SSL/TLS certificate covers both the root domain and the www subdomain. An incorrect or incomplete certificate configuration can cause redirection issues.

  5. Caching: If you've recently made changes, be aware that Amplify might cache certain responses. You may need to invalidate the cache or wait for it to expire before seeing the changes take effect.

  6. Amplify Console Settings: Double-check your Amplify Console settings, particularly in the "Rewrites and Redirects" section, to ensure there are no conflicting rules that might be overriding your www to non-www redirect.

If after checking these points the issue persists, you may need to remove the domain from your Amplify app entirely and then re-add it, ensuring you include both the root domain and www subdomain during the process. This can sometimes resolve persistent redirection issues.

Remember that changes in DNS and redirection rules can take some time to propagate fully. If the problem continues after implementing these suggestions and waiting for a reasonable propagation time, you may need to contact AWS Support for more specific troubleshooting related to your account and application setup.

Sources
I getting the 301 issue while deploy my code in the aws amplify | AWS re:Post
Root domain redirection is not working on AWS Amplify with a custom domain. | AWS re:Post
Custom domain for Amplify not working | AWS re:Post

profile picture
answered 5 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions