You deployed your React app that uses a router like “React Router Dom” to Netlify, it works fine when you visit the home page but when you click on any other link to navigate away you get a “Page not found”
and you’re wondering why this is happening when the same links works well on your local machine?.
Worry not, you’re just a file away to fixing the bug, all you need to do is configure redirects and rewrite rules for your links.
Netlify makes these redirect configurations so easy with the following steps;
1. In your favorite code editor on your local Machine,
2. Locate the Public folder, create a file with the name “_redirects” (without the quotes).
3. Open the “_redirects” file, and write /* /index.html 200
4. This redirect rule will serve the index.html instead of giving a 404 no matter what URL the browser requests.
5. Save, rebuild and redeploy your app to Netlify
6. Go back to your live app and reload
7. Revisit the links
That’s all there is to it.
For more information about Redirects and Rewrites.