Skip to content

root domain does not redirect to subdomain in amplify

0

I own the domain derbyware.com in Route 53, I deployed a static website with amplify. I want the website to be served on nidam.derbyware.com which works derbyware.com to always redirect to nidam.derbyware.com so that only that the subdomain serve the website. right now derbyware.com also serve the website, it does NOT redirect to nidam. subdomain.

config

as you can see in the image the root domain is set to serve the branch staging, which is the only branch there is. so after searching I found that I should add this rule in redirects. I'l taking about the first rule, the second one is there by default

[
  {
    "source": "https://derbyware.com",
    "status": "302",
    "target": "https://nidam.derbyware.com"
  },
  {
    "source": "/<*>",
    "status": "404-200",
    "target": "/index.html"
  }
]

but it still does not work.

Note the that when I login and go to https://us-east-1.console.aws.amazon.com/amplify/apps/d1rnle5j0ejefa/domains I see this error message that says "The role with name AWSAmplifyDomainRole-Z32DQIOI2NLNAJ cannot be found." in case that's related.

how can i have have derbyware.com redirect to nidam.derbyware.com. Thanks.

3 Answers
0

can you verify in Amplify Console → Hosting → Custom domains that:

  • Both derbyware.com and nidam.derbyware.com are listed
  • Their status shows as "Available"
  • SSL certificates are properly provisioned

Also change the redirect rule

[
  {
    "source": "https://derbyware.com",
    "status": "301",
    "target": "https://nidam.derbyware.com"
  },
  {
    "source": "https://www.derbyware.com", 
    "status": "301",
    "target": "https://nidam.derbyware.com"
  },
  {
    "source": "/<*>",
    "status": "404-200",
    "target": "/index.html"
  }
]

301 is for Permanent Redirect

answered 10 months ago

  • yes they are listed and available see picture https://imgur.com/a/lKig1ls added your redirect rule it still does not work

  • your setup looks good. DNS propagation can take up to 48 hours (usually much faster). CloudFront distribution updates take 15-30 minutes. You can check propagation status using tools like nslookup or online DNS checkers.

0

Based on your issue, there are a few things to check to get your root domain redirection working properly in AWS Amplify:

  1. First, make sure both your root domain (derbyware.com) and subdomain (nidam.derbyware.com) are added in the Amplify domain management. This is a common oversight - you need to include both domains in Amplify's domain settings for the redirection to work properly.

  2. For the redirect configuration, your rule looks close but might need adjustment. Try this format instead:

{
"source": "/",
"status": "302",
"target": "https://nidam.derbyware.com"
}
  1. In your Route 53 configuration, ensure you have:
  • A CNAME record for "nidam.derbyware.com" pointing to your Amplify app
  • An A record alias for "derbyware.com" pointing to your Amplify app
  1. The error message about "AWSAmplifyDomainRole" could be related to permissions issues. This role is used by Amplify for domain management. You might need to recreate this role or check IAM permissions.

  2. In the Amplify console under domain settings, make sure you've selected the option "Setup redirect from https://derbyware.com to https://nidam.derbyware.com".

If the issue persists after these changes, try removing both domains from Amplify and adding them again, making sure to include both the root domain and subdomain in the process.
Sources
Root domain redirection is not working on AWS Amplify with a custom domain. | AWS re:Post
I getting the 301 issue while deploy my code in the aws amplify | AWS re:Post
Custom domain for Amplify not working | AWS re:Post
Route53 redirect HTTPS from A to CNAME | AWS re:Post

answered 10 months ago

    1. they are both added.
    2. tried the redirect configuration, it does not work.
    3. in route 53: Record name derbyware.com Record type A Value *******.cloudfront.net. Alias Yes and it says Route traffic to : Alias to CloudFront distribution and Record name nidam.derbyware.com Record type CNAME Value *********.cloudfront.net Alias No and Record type : CNAME - Routes traffic to another domain name and to some AWS resources
    4. that's not helpful, I don't know what that means.
    5. "Setup redirect from https://derbyware.com to https://nidam.derbyware.com"" there is no such option.
0

Can you try this redirect URL.

[
  {
    "source": "https://derbyware.com/<*>",
    "target": "https://nidam.derbyware.com/<*>",
    "status": "301"
  }
]
EXPERT

answered 10 months ago

  • it also doe not work, I think it is a bug in amplify, especially since I get this "The role with name AWSAmplifyDomainRole-Z32DQIOI2NLNAJ cannot be found." when visiting the custom domain page

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.