My next.js app is hosted in AWS Amplify and domains are setup in Route53.
I have 3 different domains in the app, www.example1.com, www.anotherexample.com, www.thenextexample.com.
I want to redirect a specific path to another page on the same domain only. I do not want to redirect the same page if it exists on the other domains.
I tried the following but the page did not redirect as expected.
{
"source": "www.example1.com/a-custom-page",
"status": "301",
"target": "www.example1.com/dynamic-page"
},
If I try the following the redirect works but it obviously redirects all domains to the new path.
{
"source": "/a-custom-page",
"status": "301",
"target": "/dynamic-page"
},
The dynamic-page must be accessible on second and third domains but only redirected if the request is from the first domain.
Is Amplify not able to redirect based on the root domain?