Although I don’t have a specific example, what you can do is make use of the $CONTEXT environment variable and pass it through to a script, as detailed here:
As a very small example workflow, we could “pass on” the
$CONTEXTvariable into a file that you can access at browse time, like this, during build:
npm run build && echo $CONTEXT > public/netlify-context.txt
In theory, you could:
- Have different
_redirectsfiles, based on contexts (i.e. _redirects-prod, _redirects-prev) - In your bash script, look for a specific context and move the respective _redirects-[context] file to _redirects
- Enjoy your sweet, sweet context-derived redirects
