What this thread does
The problem
A React, Vue or Vite single-page app works when you click around, but opening or refreshing /dashboard directly returns the host's 404 Not Found.
What the sources say
- Netlify's rewrites and proxies docs give the fix: a rewrite (status
200) keeps the URL and serves the file. In_redirects:/* /index.html 200. Innetlify.toml: a[[redirects]]block withfrom = "/*",to = "/index.html",status = 200. The docs say this will serveindex.htmlinstead of a 404 for any URL, that existing files take precedence unless you force the rule (!in_redirects,force = trueinnetlify.toml), and that this catch-all is typically the last rule. - A Stack Overflow question is the same problem with react-router; a related Vite question covers routes failing after deployment despite working in local production testing.
- Other static hosts need their own equivalent (a rewrite or fallback to
index.html); check your host's docs rather than copying the Netlify file.
How to describe it to your agent
Our deployed SPA returns 404 when I reload a client-side route. Find which host serves the build output and add that host's rewrite-to-index rule (for Netlify a200rewrite for/*to/index.html, placed after specific rules). Make sure the_redirectsfile ends up in the build output folder (for Vite,public/). Then curl a deep route and show me the status code.
Mistakes to check
- Using a
301or302instead of200, which changes the URL instead of rewriting it. - Putting
_redirectsin the project root when the build output folder isdist. - Putting the catch-all before API or function rules.
- Rewriting everything including missing assets, hiding broken file paths.
Limits
From Netlify and Vite docs and the linked Stack Overflow questions; not tested by me. The public/ folder detail depends on your build tool.
Primary source
Primary source: Netlify rewrites and proxies (Netlify, docs). Checked 2026-11-15: a status 200 makes a rewrite that keeps the visitor's URL; the single-page-app rule /* /index.html 200 in _redirects and the equivalent [[redirects]] block in netlify.toml (from = "/*", to = "/index.html", status = 200); unmatched URLs get index.html instead of a 404; existing files win unless forced (! in _redirects, force = true in netlify.toml); the SPA rule is typically the last rule listed. Not checked: the Render and Vercel equivalents for other hosts (the Netlify source covers Netlify only). Also checked: Vite's public directory and build entry point, and the Stack Overflow questions linked above.
Started from a post by @Netlify docs, packaged by the editor. Original post