React Site using react-router published in Netlify with Page Not Found Error. Where should I put my _redirects file without a public folder?

Hi! I’m having the Page Not Found error in my React website.

I’m using react-router for my current project and I’ve seen in other solutions that you just have to have a _redirects file with the following line in it:

/* /index.html 200

But I didn’t structure my project with a public folder like so:

image

Where should I put my _redirects file?

I’m using Parcel as my bundler for this project.

Fixed it! Here are the steps I did for the fix:

  1. Parcel stores their builds into the /dist folder. I edited my .gitignore to include /dist to be pushed in github since it was excluded in the first place.

  2. I then went into my github repo of the project and navigated to the /dist folder and created a new file called _redirects and added the line:

    /* /index.html 200

That should trigger building in Netlify and that’s it.

Here’s the link to the fix tutorial: https://www.netlify.com/blog/2017/05/04/how-to-do-redirects-on-netlify/

1 Like