gatsby-plugin-netlify: _redirects file in static folder is not recognized

Created on 3 Jul 2018  路  2Comments  路  Source: gatsbyjs/gatsby

Hi,

I'm trying to redirect the default Netlify subdomain to my primary domain as advised by Netlify for SEO purposes. In the Gatsby docs of the Netlify plugin it says:

You can also create a _redirects file in the static folder for the same affect.

So I added a file at src/static/_redirects with the content it says on the Netlify admin app:

# Redirect default Netlify subdomain to primary domain https://mydomain.netlify.com/* https://mydomain.com/:splat 301!

However, after deploying if I go to the Netlify subdomain I do not get redirected to my primary domain and stay on the subdomain. What am I doing wrong?

This is the first (minor) issue I have where I didn't find any solution in the docs or in existing issues on GitHub. So, I really appreciate the great work of the community! Thanks in advance.

question or discussion

Most helpful comment

Good idea, I forgot about that. It didn't contain the file, but the resulting public folder structure gave me an idea: My location of the static folder was wrong. After I changed it from root/src/static/_redirects to root/static/_redirects, it now works. It also says so in the docs. Not sure why I didn't see that before. :-)

Thanks and issue closed!

All 2 comments

hey, if You run gatsby build locally on your machine, does generated public/_redirects file contain your custom entries? It did last time I checked

Good idea, I forgot about that. It didn't contain the file, but the resulting public folder structure gave me an idea: My location of the static folder was wrong. After I changed it from root/src/static/_redirects to root/static/_redirects, it now works. It also says so in the docs. Not sure why I didn't see that before. :-)

Thanks and issue closed!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rossPatton picture rossPatton  路  3Comments

brandonmp picture brandonmp  路  3Comments

magicly picture magicly  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

theduke picture theduke  路  3Comments