Redirect with status 404


All my redirects are working fine, using a netlify.toml file, except for when I’m using status = 404

from = "/v/*"
to = "/"
status = 404

I do get a 404 as intended, but it’s not redirecting to /?



@andylemaire The 404 status isn’t a redirect, this is explicitly mentioned in the docs:

  • 404: not found code. You can use this status code to present custom 404 pages when visitors access paths on your site that don’t exist. With this status code, the page content will change, but the URL in the browser address bar will not.

@nathanmartin thanks, I’ve seen that but then why are all examples defining a to = "..."? That’s unclear for me. “The page content will change”, so just the custom 404 page is the content.

I believe it’s intended to be the page shown as per:

# Show a custom 404 for this path
/ecommerce    /store-closed  404

So someone visiting /ecommerce would remain at that route, but receive the content of /store-closed served with a 404 status, and I believe /ecommerce would need to not exist as a file (actually be a 404).

If it were:

# Show a custom 404 for this path
/ecommerce/*    /store-closed  404

Then /store-closed would be the custom 404 contents shown for any 404’s occurring under that path, e.g. /ecommerce/this-page-does-not-exist

Which aligns with the explanation just below the other:

I agree on your thoughts, so in my case I would expect the content of the / (homepage) then, right?
Which isn’t the case.

@andylemaire That’s what I would expect for any page under /v/* that doesn’t exist, and where you don’t have something else in front of the Netlify redirects engine, for example:

Hmm, I am using Next.js. Will take a look at that. Thanks!