Redirect Config while keeping the app agnostic from deployment-env?

Hi! :smiley:

Is there any way to setup redirects without committing a dedicated file to the repository?

I feel like I should keep the app agnostic from its deployment, thus all required information (like api endpoints and such) are injected via env-variables.

What I would like to achieve is to simply redirect from the netlify sub-domain to my main-domain. Even with a netlify.toml this is kinda tricky - at least if you’d like to inject the “from-” and “to-urls” via env-vars and not hardcode them into the file.

Wouldn’t it be sensible to additionally provide an input mask (textarea) in the netlify ui to specify things like redirects? Am I missing something?

Thanks for clarifying :slight_smile:

Dang, not two weeks ago was I looking at something similar!

In short, it is possible (to redirect to your main domain) but you’re gonna need a redirect, either in the .toml or a _redirects file. The beauty of keeping these out in a file is, with a bit of jiggery-pokery, you can make them context-based. You want certain redirects for prod versus dev? Great! Deploy previews need handling differently? Sorted!

Your rules themselves don’t have to be hard-coded. They can be pretty flexible and we allow for things such as splats and query parameters. But, I think you mean ‘hard-coded’ in relation to the fact that they’re in a file… that said, they’d be hard-coded in the UI, no? :thinking: