user9748969
user9748969

Reputation:

Netlify Redirect not working

so yesterday I was having a problem because I wasn't able to implement a 301 redirect to my page hosted on the GitHub pages.

Today I found Netlify which should be able to do 301 redirects. However something is not working, the docs say I need to add the redirect in a _redirect file, but nothings working. Any ideas what I am doing wrong?

Here is the Test page: https://peaceful-swanson-2960b1.netlify.com/

(It should redirect to news when you click on blog)

Here is the GitHub Repo:

https://github.com/vnllab/testy

Upvotes: 4

Views: 6846

Answers (2)

Arman Bhatia
Arman Bhatia

Reputation: 11

When you deploy you react site to netlify with a react router package. it will create this issue where you are unable to refresh the child pages on the deployed site. It happened with me and then I went online and found this solution. Try to add this file and with all the redirect mention it should work.

The logic behind this is when you are fetching data from a netlify server with a child root. let fetch("example.netlify.com/my-root") // this will give an page not found error as on netlify there is no my-root

Upvotes: 0

mrtnmgs
mrtnmgs

Reputation: 1562

2 things:

  • you mention the _redirect file. It should be _redirects.

  • I had an issue with a redirect. It took me a while to figure out that if I put a catch-all rule first, the other rules would never be reached (well at least that's what I think was happening, my other rule was ignored...).

This:

/* /index.html 200
http://mysite.netlify.com/* https://mysite.netlify.com/:splat 301!

didn't work, but this:

http://mysite.netlify.com/* https://mysite.netlify.com/:splat 301!
/* /index.html 200

works fine...

Upvotes: 18

Related Questions