How do I make a Netlify redirect override an existing file?

The Citead team, updated

In short. Add ! after the status code in _redirects or set force = true in netlify.toml to override matching files.

Definition: As of 17 October 2026, a forced Netlify redirect overrides an existing file matching the requested path. It uses ! after the status code in _redirects, or force = true in netlify.toml.

Key facts

What configuration overrides the file?

Netlify's force redirects instructions apply the force option to the rule's status. For a permanent move, the following adapted example combines status 301 with the forcing suffix:

/best-pets/dogs  /best-pets/cats.html  301!

The equivalent configuration in netlify.toml keeps the status numeric and adds a separate Boolean setting:

[[redirects]]
from = "/best-pets/dogs"
to = "/best-pets/cats.html"
status = 301
force = true

The source path is /best-pets/dogs; the destination is /best-pets/cats.html. Status 301 tells the client that the address has permanently changed and changes the browser's displayed address. The force option allows the rule to override matching content at the source path.

How does file shadowing affect rewrites?

File shadowing is the default behavior in which an existing file takes precedence over a matching routing rule. A rewrite serves another resource while preserving the requested URL. Netlify's rewrites and proxies documentation gives this forced rewrite:

/best-pets/dogs  /best-pets/cats.html  200!

In Netlify's example, /best-pets/dogs displays the cats page even when /best-pets/dogs/index.html exists. The 200 status makes this a rewrite; the exclamation mark makes it override the existing file.

The same documentation shows a broader forced rule:

/app/*  /app/index.html  200!

This serves /app/index.html for everything matched under /app/*, including paths that match deployed files. An ordinary single-page app fallback preserves existing files through shadowing. Adding force changes that behavior across the matched paths, so the scope of the rule matters.

What should be checked if the rule still fails?

Netlify's configuration overview places _redirects in the publish directory, the folder containing the finished files deployed after a build. A generated site's build output must contain that file for Netlify to read its rules.

The same overview specifies that matching proceeds from top to bottom and stops at the first matching rule. An earlier rule can therefore prevent a later forced rule from being reached. A specific exception belongs above a broader matching rule. When both configuration files contain rules, checking _redirects first follows Netlify's processing order. Source paths also require the correct letter case because matching is case-sensitive.

FAQ

Should I use 301! or 200!?

Use 301! when the browser should move to the destination address permanently. Use 200! when the destination's content should appear at the original URL, following Netlify's status code documentation.

Can I force only one path?

Yes. Netlify's shadowing examples include an individual /best-pets/dogs rule as well as an /app/* rule. Choose the individual path when only that route needs to override an existing file.

Sources

  1. Netlify, "Redirect options", 17 September 2026
  2. Netlify, "Rewrites and proxies", 14 July 2025
  3. Netlify, "Redirects and rewrites", 14 July 2025

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark