_redirect Not Working with React Vite on Netlify

I’m experiencing an issue with routing in my React + Vite project deployed on Netlify.

Locally, everything works fine, and unknown routes are correctly redirected to index.html. However, on Netlify, the redirection doesn’t work, even with a _redirects file in the public folder or a netlify.toml file containing the following:

[redirects]  
  from = "/*"  
  to = "/index.html"  
  status = 200  

I have read previous discussions about similar issues and tried all the recommended steps, including ensuring the _redirects file is correctly located in the public folder. However, the problem persists.

The only solution that worked was switching from BrowserRouter to HashRouter, which redirects all unknown routes to the base route due to its hash-based approach. While this works, I don’t prefer this solution as it changes the URL structure and doesn’t align with how my application should function.

I don’t recall facing this issue previously, and it seems like _redirects or netlify.toml used to handle these scenarios properly.

Could you help me identify if there is a change in behavior or additional steps I need to take to make BrowserRouter and _redirects work as expected?

Thank you!

@opamusora What’s the link to the Netlify site?

Do you have a public repository?

In the case of the netlify.toml I believe it’s supposed to be [[redirects]], see:
https://docs.netlify.com/routing/redirects/#syntax-for-the-netlify-configuration-file

I tried to do what you described (use [[redirects]] instead of [redirects]) and it didn’t work, so unfortunately I won’t be able to share the repository with you. The contents of the netlify.toml file were as I described above

No worries, as a fellow community member I can’t assist you if I have to debug blind.

Best of luck getting it sorted out!

Appreciate your support!

Without a site URL or repo, I don’t believe even we can provide any assistance.