_redirects now handles rewrites and per-section 404 pages
A _redirects rule with status 200 serves another page at the requested address, the usual single-page-app fallback, and 404 serves a section's own not-found page. Rules now give way to a real file unless forced with !.
Two statuses that _redirects used to skip now work, on Level 0 sites.
200 serves another page at the same address. The visitor’s address doesn’t change; they get the target’s content. The common use is a single-page app, where every route is handled by one page:
/* /index.html 200
404 serves a section’s own not-found page, with a 404 status:
/docs/* /docs/404.html 404
A change to existing rules
A rule now gives way to a real file. If a file exists at a rule’s source path, the file is served and the rule is skipped, the same as on Netlify. That applies to 301 and 302 rules as well as the new ones, so a redirect whose source is a real file stops firing. To make a rule win anyway, add ! to its status:
/old-page.html /new-page/ 301!
Worth knowing
- Directory pages and the trailing-slash option. With
# ee:trailing-slash onleft out, a request for/aboutthat has an/about/index.htmlbehind it now gets your 404 rule’s page, not a bare 404. - A rewrite target can’t be cached as immutable. Content served at an address that isn’t its own is cached like any other file, never for a year, so the next deploy is picked up.