Redirect with query string does not work (except when it does)

I have a set of redirects setup for some sections of my website which I want paginated. For example, for my notes section, /notes/?page=2 should redirect to the page /notes/page/2.html.

Here’s one of the redirects I’ve added to my netlify.toml file:

from = "/notes/"
to = "/notes/page/:p.html"
status = 200
force = true

  page = ":p"

(When I say redirect, I mean rewrite – the URL should stay the same but a different HTML page should be fetched in the background.)

You can see an example here: This redirect will likely work the very first time you visit this page, or if you type in a pagination query manually, but will then revert to the broken state where only the first page is shown, regardless of the query string value given.

These redirects work locally when I use netlify dev:

◈ Rewrote URL to /notes/page/2.html?page=2

There are no reported errors with redirects when the site is deployed:

1222 redirect rules processed
All redirect rules deployed without errors.

The redirects playground shows this redirect syntax to be correct:

from = "/notes/" to = "/notes/page/:p.html" status = 200 force = true [query] page = ":p"

Everything seems to be present and correct. And yet.

It seems as if there’s some weird caching behaviour occurring in production, but for the life of me I can’t figure out what it might be. I have a service worker running on my site, but disabling that makes no difference either.

Can anyone point me in the right direction and help me solve this mystery?

Hey @paulrobertlloyd,

This is really strange behaviour and I could not find an explanation for it. I’ve raised it with the devs to help us understand what’s happening here.

Hey @paulrobertlloyd,

This was identified as a bug and has now been fixed. Let us know if it still happens.

@hrishikesh Oh brilliant, glad to hear it was both a bug and that it’s been fixed. Thank you!