Next up, we evaluate any redirects and rewrites. These are a simple yet powerful way of creating custom routing rules, based on different types of conditions, to any type of destination (the same site, a different Netlify site, or any site on the web).
When you target the same site, we employ some special rules that are important to know. By default, redirects behave as fallbacks, which means that a redirect rule from /foo
to /bar
actually means serve /bar
if /foo
doesn't match anything. This is typically known as shadowing and it's equivalent to the preferStatic
configuration we saw earlier.
If you'd like to opt out of this behavior and always serve the redirect destination regardless of whether the source matches something else, you can set the force
property to true
for redirects declared in netlify.toml
, or use an exclamation mark in the _redirects
file.
If the redirect matches a function, we'll follow the same evaluation logic covered in the previous step, including the check for preferStatic
, so you can think of it as going back one step in the request chain. It's important to note that this is not a recursive operation, as we won't evaluate redirects again.
When no redirect rules match, the request continues on.