One of our most frequently requested features is “automatic pass through” of query string parameters present on a URL covered by an HTTP 301 or 302 status redirect rule. We currently handle proxy redirects (HTTP 200 status) in this way, but not 301/302 redirects. For 301/302 redirects today, we can only reliably handle query string parameters which you explicitly configure to use a specific combination of query string parameters as described in our documentation. This is both brittle (a new or changed value will not be handled automatically unless you also update your redirects configuration), and leads to some workflows where a site needs thousands of redirects for a handful of paths to cover all the possible combinations of query parameter options that might be appended to a URL.
Today we are happy to announce that we have implemented automatic query string argument pass through, and intend to roll it out to our non-enterprise CDN next week. This will apply to all redirects that do not already specify a query string parameter pattern - whether to another path on the same site, a function, or a path on a separate site at Netlify or away from Netlify.
What does this look like in practice? Let’s talk through some examples!
Today, a redirect like /path /otherpath 301
will match requests to /path?var=value
- but /otherpath
is redirected to, WITHOUT ?var=value
appended. In the new world, it will work as you’re expecting: /path?var=value
will redirect to /otherpath?var=value
.
This works identically in the toml file:
[[redirects]]
from = "/old-path"
to = "/new-path"
status = 302
will redirect https://site/old-path?variable1=value1&variable2=value2
to https://site/new-path?variable1=value1&variable2=value2
Note that if you have existing (or future) query-parameter-SPECIFIC redirects like this one:
[[redirects]]
from = "/old-path"
to = "/new-path"
status = 302
query = {id = ":id"}
…those redirects will continue to apply ONLY to requests to /old-path with a query param variable named id
- so, this shouldn’t break existing configurations. If you can think of a problem that might affect your site, please bring it up in a response to this topic as soon as possible so we can talk through it with you.
This change is planned to go into effect on Monday, 4 October for the non-enterprise CDN, and the following Monday for the Enterprise CDN.