- Newest
- Most votes
- Most comments
It appears you're experiencing an issue with redirecting from your Amplify app URLs to your custom domain for your motorhome and surf applications.
The issue seems to be in how you've configured your redirect rules. When trying to redirect from the Amplify app URL to your custom domain, you need to ensure both the domain configuration and redirect rules are properly set up.
For your motorhome and surf apps, you should:
-
Make sure both the root domain and www subdomain are added in the Amplify domain management settings for each app. This is crucial for proper redirection.
-
In your redirect rules, you need to modify how you're targeting the Amplify URLs. The format you're using for source may not be matching correctly. Instead of using the full URL in the source, try using patterns that match the path:
[
{
"source": "/<*>",
"status": "301",
"target": "https://www.ourdomain.nz/motorhome/<*>"
}
]
-
Check that your custom domain is correctly configured in AWS Amplify and that DNS settings are properly propagated. This includes verifying that the CNAME records are correctly set up in your DNS provider.
-
If you're still experiencing issues, try invalidating the cache in AWS Amplify Console, as caching can sometimes cause redirect issues to persist even after configuration changes.
-
Ensure that the SSL certificates for your domains are correctly configured and active.
The endless redirect loop you experienced suggests that your rules might be creating a circular reference. Make sure your rules are specific enough to avoid this situation.
Sources
Root domain redirection is not working on AWS Amplify with a custom domain. | AWS re:Post
Issue with AWS Amplify Deployment on Custom Domain | AWS re:Post
I getting the 301 issue while deploy my code in the aws amplify | AWS re:Post
Amplify custom domain setup issue | AWS re:Post
answered a year ago
Make sure both the root domain and www subdomain are added in the Amplify domain management settings for each app
I haven't found a "domain management settting", so I assume you mean Custom domains? It appears that the same domain can not be added to multiple apps. We have it added to the core app, but attempting to add it to motorhome and surf apps are responded to in the console with One or more domains requested are already associated with another Amplify app: ourdomain.nz, www.ourdomain.nz and are not allowed to add the domain.
This is crucial for proper redirection.
How do we go about getting "proper redirection" if you won't allow us to add it?
In your redirect rules, you need to modify how you're targeting the Amplify URLs. The format you're using for source may not be matching correctly. Instead of using the full URL in the source, try using patterns that match the path:
We tried this.
Check that your custom domain is correctly configured in AWS Amplify
We've done this in core, as mentioned above, we are unable to add the same domain to the sub sites, if we had not done it, then the following domains would not be working: https://www.ourdomain.nz (works fine) https://www.ourdomain.nz/motorhome/ (works fine) https://www.ourdomain.nz/surf/ (works fine)
and that DNS settings are properly propagated
If this wasn't the case then the following would not be working: https://www.ourdomain.nz (works fine) https://www.ourdomain.nz/motorhome/ (works fine) https://www.ourdomain.nz/surf/ (works fine)
This includes verifying that the CNAME records are correctly set up in your DNS provider.
I think if the CNAME records were not properly setup in our DNS provider (CloudFlare) then the following would not be working: https://www.ourdomain.nz (works fine) https://www.ourdomain.nz/motorhome/ (works fine) https://www.ourdomain.nz/surf/ (works fine)
If you're still experiencing issues, try invalidating the cache in AWS Amplify Console
We haven't found this feature in the console, so we used invalidation in customHttp.yml files in the root of each app:
- pattern: "*"
headers:
- key: 'Cache-Control'
value: 'no-store, no-cache, max-age=0, must-revalidate'
We also have the Caching - Configuration in CloudFlare set to Browser Cache TTL 1 second, Development Mode on, and we also Purge Everything after: each change in amplify app and redeploy.
as caching can sometimes cause redirect issues to persist even after configuration changes.
We have been able to see our changes take effect, because things just break.
Ensure that the SSL certificates for your domains are correctly configured and active.
I'm not sure what SSL certs have to do with this, I'm pretty sure if they were not configured and active, then the following URLs would not be working: https://www.ourdomain.nz (works fine) https://www.ourdomain.nz/motorhome/ (works fine) https://www.ourdomain.nz/surf/ (works fine)
After the suggested change (other than the adding of ourdomain.nz and www.ourdomain.nz to Custom domains for motorhome and surf apps because the console won't allow it), when we try fetch https://main.[motorhome-app-id].amplifyapp.com we get: ERR_TOO_MANY_REDIRECTS in the browser. The browser network tools Initiator looks like: Request initiator chain https://www.ourdomain.nz/motorhome/ https://www.ourdomain.nz/motorhome/ https://www.ourdomain.nz/motorhome/ https://www.ourdomain.nz/motorhome/ https://www.ourdomain.nz/motorhome/ etc...
So as you can see, the same issue persists.
The endless redirect loop you experienced suggests that your rules might be creating a circular reference. Make sure your rules are specific enough to avoid this situation.
We used the rule you suggested, and... as you can see, the same issue persists. So... What are we doing wrong?
answered a year ago
Any help please?
Relevant content
asked a year ago
asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago

Can we have some human help please?