How do I configure custom redirects and HTTP headers with Hodifly?
Hodifly supports _redirects and _headers files, similar to Netlify, for static sites. Place them at the root of your published output (the build folder configured on Hodifly).
_redirects
One rule per line: source destination [status]. Blank lines and # comments are ignored. If you omit the status, 301 is used.
# permanent redirect
/old-page /new-page 301
# temporary redirect
/promo /summer-sale 302
# redirect to an external site (full URLs are kept as-is)
/discord https://discord.gg/xyz 302
# wildcard: :splat matches everything captured by the trailing *
/blog/* /news/:splat 301
# SPA fallback: serve index.html for any unknown path (status 200 = rewrite, URL unchanged)
/* /index.html 200
Good to know:
- Real files and folders take precedence first. An existing file or directory is always served before any redirect rule: your assets keep working, and an SPA fallback
/* → /index.html 200only kicks in for paths that don't exist on disk. - Status
200means rewrite (serve the destination without changing the URL): this is what makes single-page app fallbacks work. :splatis the only supported pattern; it captures everything matched by a trailing*.- Query strings are preserved during redirects and rewrites.
Not supported (stick to the subset above): named patterns such as /:year/:month, conditional rules (country, language, cookie, role), and forcing indicators (force flags).
Single-page apps: nothing to do
A React, Vue, Angular or Svelte app with a client-side router needs every unknown path to be served by index.html, otherwise a reload or a direct link to /some/route shows a 404. Hodifly adds that fallback automatically when your build's only page is an index.html that starts a JavaScript app, so you no longer need the /* /index.html 200 line above.
- A missing file in a real folder (
/assets/app.js) stays a 404, and a project mounted in a subfolder (/api/) keeps answering its own URLs. - The automatic fallback steps aside as soon as you handle routing yourself: a
_redirectsfile, avercel.json, or aRewriteRulein an.htaccessyou ship. - To turn it off, set
"spa": falsein yourhodifly.json."spa": trueforces it on a build that does not look like a single-page app.
_headers
A path line starting with /, followed by indented Name: value header lines. # comments are ignored.
# apply to every response
/*
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
# apply only under a specific path
/assets/*
Cache-Control: public, max-age=31536000, immutable
Good to know:
/*or/applies the headers to the entire site.- A specific path like
/assets/*applies them to requests under that path.
Updated on: 05/10/2026
Thank you!