Wildcard redirect not working

In my _redirects file:

/admin/* /admin/ 301

Whenever I visit e.g. /admin/dashboards, I would expect to be redirected to /admin/. However, I just get a 404. What am I missing?

It’s hard to say with only a fragment of the information provided.

You should confirm that your _redirects file is actually making it into the files that you’re deploying, check your build log to make sure it says your redirect rules were processed.

If your redirects are being found and applied, then ensure that you’ve adhered to the Rule processing order.

_redirects file is there. It says the rules were processed.

Also, I only have one more rule defined, which is for “/”, so e.g. /admin/ should definitely not match that.

@bageren Instead of just describing it, can you show the contents of the _redirects?

Are you able to provide a link to your site?

Hi, @bageren. My best guess is that the rule needs to be “forced” with an exclamation mark like so:

/admin/* /admin/ 301!

That is required because of the file shadowing behavior:

https://docs.netlify.com/routing/redirects/rewrites-proxies/#shadowing

If that doesn’t work, please let us know.