-1

I hosted one of my website on Netlify. Site was built with ReactJS.

After deploying on Netlify, I can view the homepage but can't load any of the other pages.

Site works totally fine in localhost.

Is this a problem with routing?

I used react-router for routing.

enter image description here

msefer
  • 331
  • 2
  • 10
Meraj Kazi
  • 65
  • 10

2 Answers2

1

Try to create a new file in your project public folder called _redirects then add this inside it

/* /index.html 200

its been solved here before Netlify does not recognize the URL params when using react-router-dom

Mohamed Salah
  • 271
  • 1
  • 7
  • this worked. Also found this solution in this blog too. https://dev.to/rajeshroyal/page-not-found-error-on-netlify-reactjs-react-router-solved-43oa – Meraj Kazi Dec 22 '21 at 13:42
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Vimal Patel Dec 22 '21 at 14:33
  • 1
    @VimalPatel I did answer his question, the answer is basically that line – Mohamed Salah Dec 23 '21 at 01:25
0

Just found this blog post. This gives a good explanation.

Creating a file called _redirects in the public folder and adding this code

/* /index.html 200

solves the problem.

https://dev.to/rajeshroyal/page-not-found-error-on-netlify-reactjs-react-router-solved-43oa

Meraj Kazi
  • 65
  • 10