Hi! I have a Gatsby site that I can’t get the redirects working for. I’m spinning my wheels.
My file content:
* I've validated my redirects with the validation tool. It's valid
* The redirects are housed in the `_redirects` file in `src/`.
* I also tried setting them up in the `gatsby-node.js` file with wild cards and not.
* I force redirects from non-slash to slash on the page build. Knowing this, I tested out both redirects that include and exclude the original page's redirect. E.g. `/lesson-plan/scratchjr/enter-string-here /scratchjr/` and `/lesson-plan/scratchjr/enter-string-here /scratchjr`
* I tested both non wild card and wild card versions of this file (there's about 400 URLs that need redirected)
* Sometimes the redirect works and white screens.
Any ideas on what it could be? I happy to post more details!
Hi, @bootuppd. Netlify won’t read the _redirects file from that directory. That file needs to be placed in the publish directory for the site or the base directory of the repo for Netlify to process it.
For Gatsby, any static files places in the static directory will be automatically copied by Gatsby to the publish directory:
Please try adding the _redirects file there and then triggering a new deploy. If that doesn’t resolve the issue, please let us know.
The solution if you want to force a redirect even when files exist for the path in question is to force the redirect using ! after the status code. If left blank the default status code is 301 for redirect rules.
If you want to force the redirect for sub-paths of /lesson/scratch/, then the redirect rule required is this instead:
/lesson/scratch/* /student-portal 301!
If you make that change and it still doesn’t work (or if there are other questions), please reply anytime.