-2

I have a build a React website and hosted in Hosting er. When i go to website and open another page and refresh, it's showing "Oops, looks like the page is lost." How i will resolve this bug? Is this problem with routing in React?

I need fully functional website like when i run in my system. But when hosted the pages are not working properly.

Fahad
  • 1
  • 1
  • url rewrite in the concept you want to look into Check this link to understand https://stackoverflow.com/questions/58452840/react-router-throwing-404-upon-page-refresh-with-react-app-hosted-on-godaddy – Bipin Nov 19 '22 at 05:39

1 Answers1

0

The reason the website shows 404 is because in react all routes go to the index.html to render the components. But in a standard hosting it will look for a HTML file in the route's directory which doesn't exist in a React Application. Hence we configure our hosting service to redirect all request to the root index.html.

In your case since you have hosted on Hostinger you may use the follwoing guidelines to make updates to your .htaccess.

Official Guidelines from Hostinger:

https://www.hostinger.in/tutorials/what-is-react#How_to_Deploy_a_React_Application_on_Hostinger

M. G.
  • 343
  • 1
  • 7