In short. Preserve query string makes Cloudflare use the incoming query and discard the query written in the target URL.
Definition: Cloudflare Bulk Redirects can replace the query string written in
target_urlwith the query string from the incoming request. This happens whenpreserve_query_stringis enabled, including when the incoming request has no query string.
Key facts
- Cloudflare defines Bulk Redirects as account-level redirects that send a client from a source URL to a target URL with an HTTP status code.
- Cloudflare's URL redirect parameters reference says
target_urlis mandatory and that the final target depends on the query-string and path-suffix parameters. preserve_query_stringis a Boolean whose default isfalse.- When it is
true, the redirect URL keeps the query string from the original request. - The incoming query string replaces the target query string. Cloudflare says the target query is discarded even when the incoming request has no query string.
- To add a fixed query parameter, Cloudflare says to leave this option disabled and put the parameter in
target_url.
What exactly gets discarded?
Cloudflare's URL redirect parameters reference describes target_url as the URL where the client is redirected after a match. With query preservation enabled, Cloudflare takes the query string from the request that matched the source URL and uses it for the final redirect URL. The target's own query string therefore is not merged with the incoming one.
Cloudflare's reference gives this example for a redirect from /my-folder/ to /other-folder/: a request for /my-folder/?name=value becomes /other-folder/?name=value when Preserve query string is enabled. If the option is disabled, the same request becomes /other-folder/. The same reference states that a query string already present on the target is discarded when preservation is enabled, even if the request has no query string of its own.
Which setting controls the result?
Cloudflare's parameter reference documents the relevant API fields as follows:
{
"source_url": "String",
"target_url": "String",
"preserve_query_string": false
}
The source_url and target_url fields are mandatory URL strings. Cloudflare gives each a maximum length of 32 KB. The preserve_query_string field defaults to false, so a fixed query in target_url remains available when the option is left disabled. Enabling it changes the final URL to use the original request query instead.
This setting concerns query strings. Preserve path suffix is a separate parameter and applies only when Subpath matching is enabled. The reference's path example sends /my-folder/foo to /another-folder/foo when both settings are enabled.
What else is part of the Bulk Redirect behavior?
Cloudflare's Bulk Redirects overview describes Bulk Redirects as essentially static. They do not support string replacement operations or regular expressions, although their parameters change source matching and redirect behavior. The documented status-code values are 301, 302, 307, and 308. The 307 and 308 choices preserve the original HTTP method when the client follows the redirect.
Bulk Redirects run after the WAF in Cloudflare's request-processing pipeline. The Bulk Redirect does not execute when a WAF custom rule or rate-limiting rule blocks the request. Cloudflare also lists Trace a request as the tool for determining whether a bulk redirect rule triggers for a specific URL.
Related terms
- HTTP redirects
- How do I keep campaign parameters through redirects?
- How do Cloudflare Pages redirects handle query strings?
FAQ
Does Cloudflare append the incoming query to the target query?
No. With Preserve query string enabled, the incoming query replaces the target query. Cloudflare documents the target query as discarded.
What happens when the incoming URL has no query string?
The target query is still discarded when preservation is enabled. The final redirect therefore uses the target URL without that configured query string.
How can a redirect keep a fixed query parameter?
Leave Preserve query string disabled and include the fixed parameter directly in target_url, as Cloudflare's parameter reference instructs.
Sources
Check how a page reads to answer engines. Open the GEO score analyzer