If you to this page and refresh the window it gives you a 404 page not found error. This is because I used react-router in my website which rewrites the URL. Because of this, everytime I refresh a page it throws error 404. How do I fix this? Do I set a custom .htacess command to fetch so and so content at some URL?
Yes! This is exactly what youâre supposed to do!
When you load the home page and then navigate to another page, Javascript is used to manipulate the path shown in the browser. When you refresh the page, the browser requests the page from the server. But the server doesnât know the request should be forwarded to the HTML file serving the React app. So you need to tell the server to do that.
Definitely! I gave you one! Please try it, itâs much cleaner than the solution youâre using now and doesnât require you to add multiple pieces of configuration for every page you want to add.