I can't get the 301 redirect to work in Netlify at all (I've seen other answers, but it doesn't work).
I've made the _redirects file and placed it in the root of my github ripo.
https://some-domain.netlify.com/* https://www.mydomain.tk/:splat 301!
I expect it that when someone types this: https://some-domain.netlify.com/ he will be redirected to here: https://www.mydomain.tk , but that doesn't happen.
Thanks for the help
The issue is that the _redirects
file does not go to the root of your repository unless the root of your repository is your deploy path.
The _redirects
file must be placed into the root of your deploy path.
In the case below, the deploy directory after the build command is public
in the repository.
root
├ public
| ├ _redirects
| └ index.html
├ src
└ lib
Note: Remember that you can also put redirects in your netlify.toml
file. The netlify.toml
file does go in the root of the repository.
netlify.toml
[build]
command = "npm run build"
publish = "public"
[[redirects]]
from = "https://some-domain.netlify.com/*"
to = "https://www.mydomain.tk/:splat"
status = 301
force = true
There is a playground to build them from the _redirects
format to netlify.toml
format