amplify-hosting
amplify-hosting copied to clipboard
Support redirecting specific route of a specific subdomain
Is your feature request related to a problem? Please describe. I'm trying to redirect a specific path of a specific subdomain to another url. The Amplify redirect rules only appear to allow redirecting every route of a subdomain or redirecting a specific route of every subdomain.
Say I have 2 subdomains redirect.example.com
and noredirect.example.com
. I would like
-
redirect.example.com
andredirect.example.com/
to redirect tosomemarketingdomain.com
-
redirect.example.com/all-other-paths
,noredirect.example.com
,noredirect.example.com/
, andnoredirect.example.com/all-other-paths
to not redirect
I think this is a feature request since I've tried a bunch of things and haven't figured it out. Here are my attempts:
- Write redirect rule for the root path:
Doesn't appear to do anything and doesn't satisfy number 1 or 2 of my requirements above.[ { "source": "https://redirect.example.com/", "target": "somemarketingdomain.com", "status": "302", "condition": null }, ]
- Write redirect rule for every domain:
Satisfies number 1 above but doesn't satisfy number 2 since[ { "source": "/", "target": "somemarketingdomain.com", "status": "302", "condition": null }, ]
noredirect.example.com
also redirects. - Write redirect rule for the whole subdomain:
Satisfies number 1 above but doesn't satisfy number 2 since[ { "source": "https://redirect.example.com", "target": "somemarketingdomain.com", "status": "302", "condition": null }, ]
redirect.example.com/all-other-paths
also redirects.
Describe the solution you'd like I would like for my attempt number 1 to work where you can redirect specific routes for a specific domain
Additional context I saw that https://github.com/aws-amplify/amplify-console/issues/233#issuecomment-558835732 suggested creating a new Amplify app for each subdomain, in which case my attempt number 2 would work. But this seems like overkill and a really hacky solution with duplicate config and more room for error.
It seems like requiring one Amplify app per subdomain defeats the purpose of all the domain management features and being able to quickly change which subdomain points at which branch.
Use cases I see for this:
- Test redirects on staging before production. I would like to test a redirect on
stage.example.com
before moving it into production atexample.com
- Migrating to a new domain. If I wanted to migrate incrementally from
domainone.com
todomaintwo.com
, I could only redirect some routes until we were ready to move them all without having to create a whole separate Amplify app. - The ability to have a shortcode domain served from the same repo. Say I had
example.com
andex.app
and only wantedex.app
to serve/a/123456
routes, otherwise redirect to the main app.
Hi @OzzieOrca,
Thanks for the reporting this with a detailed explanation :) Currently we don't support the functionality to skip certain routes under a given subdomain during redirects. We have added this as a feature request to our current backlog.
Thanks for prioritizing it. 😄 Guess I'll need to make multiple apps for now. 😦 I appreciate the answer and the clarification of the current redirect support.
I'm facing the same scenario we have a project landings
that contains a ton of miniprojects for marketing, etc and we
want to use subdomains with a wildcard would be perfect. Just commenting to rise a little bit the priority :D thanks!
I have the same scenario described by @luishdez. This would be super helpful.
Same issue here, would be great if this feature can be done.
some scenario is needed, but would be also perfect to allow some access (per redirect) per IP address. Cause I do not want everybody to watch things which I do not want to share at a specified time
Same issue. Will be helpful to have some updates here.