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.
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!
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/_redirectstoroot/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!