Rewrites not working netlify.toml

Hey all,

For some reason my rewrites aren’t working? And it really doesn’t seem hard…

This is the rewrite part in my netlify.toml:

[[redirects]]
from = "/wedstrijden/:race"
to = "/races/:race"
status = 200

[[redirects]]
from = "/nl/wedstrijden/:race"
to = "/nl/races/:race"
status = 200

Site ID: 0e3356e3-6bc6-4270-a8ce-1ac9b4b2aa74

Gr,

Andy

Hi Andy,

It looks like your syntax is a little off, you’ll want to update the rewrite to use a splat instead:

[[redirects]]
from = "/wedstrijden/*"
to = "/races/:splat"
status = 200
force = true

Thanks for the tip @sid.m, but that also doesn’t seem to work…

When I attempt to test this redirect, I’m getting a 401 unauthorized error when navigating to dev.andylemaire.be. Do you have some type of auth enabled on the site?

Yes, i use it as a private test environment.

Gr,

Andy

@modcarparking the strange thing is that all my redirects work perfectly (I have about 27 redirects) when using Netlify CLI to confirm everything locally. But after deploy the translated url’s don’t work, and the next one does work:

[[redirects]]
from = "/events/:event/:race"
to = "/races/:race"
status = 301
force = true

I have no extra spaces, my editor removes those. The target path does exist and as stated above, locally using Netlify CLI to test it, it’s all fine. I’m using Next.js but there are no rewrites/redirects in there. And I’ve cleared Netlify cache + browser cache 100 times…

Gr,

Andy

Small update, I’m using Next.js also. I now expect that the Netlify rewrites don’t work in combination with Next.js but I can’t find documentation of the recent Runtime, only the Legacy Runtime.

Gr,

Andy

Don’t know if this is the correct way, but I moved all rewrites/redirects to the Next.js config instead of netlify.toml. I always thought netlify.toml was preferred.

By not working, if you mean you were getting a 404, I think this is currently expected behaviour, explained here: Can't seem to be able to exclude root from a redirect rule - #18 by hrishikesh

We do intend to provide another configuration option to change the behaviour though (so the Function would receive the new URL instead of the original one), however it’s currently not priorotised.