1

Whenever I refresh a page on my deployed netlify site I'm being redirected (as planned) to the main page.

But the url path itself doesnt change.

Is it something I need to set in the .toml file or its something with my react routes?

I'm using:

  • <BrowserRouter/> of react-router-dom to be my router.
  • netlify.toml file

netlify.toml:

[[redirects]]
from = "/*"
to = "/index.html"
status = 200
ueeieiie
  • 1,014
  • 10
  • 33

1 Answers1

4

The behavior you are seeing is documented to rewrite the path. This is the behavior you may want to see for history pushstate in a single page app using react on Netlify so no matter what url path is in the browser request, it will not give a 404.

If you want to redirect your path you would use a valid 300 status code (301, 302 or 303) like so:

[[redirects]]
from = "/home"
to = "/"
status = 301
talves
  • 11,477
  • 3
  • 31
  • 55