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?
<BrowserRouter/>
of react-router-dom to be my router. netlify.toml:
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.