New Transparent capture is in preview. Record every app's traffic with no proxy configuration, on Windows, macOS and Linux. Learn more

changeRequestPathAction Action

Rewrite the path and query string of matching requests before they reach the upstream, useful for routing legacy clients to new endpoints.

URL rewriting is one of the most common reasons engineers reach for a proxy. A legacy client points at the wrong route, a canary needs traffic before DNS catches up, or a third party SDK ships with a typo. changeRequestPathAction lets you fix the path in flight from a YAML rule, so the client keeps working while the real fix is being prepared.

When to use this action

Use changeRequestPathAction when the path the client sends needs to be rewritten before it reaches the server. The host stays the same, only the path and query string are replaced.

Typical situations include:

  • Pointing a legacy client that calls /api/v1/... at the new /api/v2/... routes without redeploying it.
  • Sending a percentage of traffic to a canary endpoint while the rest goes to the stable one.
  • Working around a bug in a third party SDK that hard codes the wrong URL.
  • Mapping a public path to an internal one when testing against a debug surface.

The action evaluates on requestHeaderReceivedFromClient. The whole path including the query string is replaced, so include the query in newPath if you need to keep one.

Real world examples

Rewrite legacy v1 endpoints to the v2 path

Useful when a desktop client still calls the old API. The rewrite is transparent to the client and you avoid shipping a new build.

rules:
- filter:
    typeKind: FilterCollection
    operation: And
    children:
    - typeKind: HostFilter
      pattern: api.example.com
    - typeKind: PathFilter
      pattern: ^/v1/(.*)$
      operation: Regex
  actions:
  - typeKind: ChangeRequestPathAction
    newPath: /v2/{0}

Force every request to hit a canary endpoint

Combine with a tight filter so only one client or environment is rerouted. The upstream sees the canary path.

rules:
- filter:
    typeKind: FilterCollection
    operation: And
    children:
    - typeKind: HostFilter
      pattern: api.example.com
    - typeKind: PathFilter
      pattern: /search
  actions:
  - typeKind: ChangeRequestPathAction
    newPath: /search?canary=true

Redirect a single buggy URL on a third party SDK

The SDK calls the wrong endpoint and you cannot patch it. Rewrite the path in flight while a fix is shipped.

rules:
- filter:
    typeKind: PathFilter
    pattern: /broken/old-endpoint
  actions:
  - typeKind: ChangeRequestPathAction
    newPath: /healthy/new-endpoint

Reference

changeRequestPathAction

Description

Change request uri path. This action alters only the path of the request. Request path includes query string.

Evaluation scope

Evaluation scope defines the timing where this filter will be applied.

requestHeaderReceivedFromClient This scope occurs the moment fluxzy parsed the request header receiveid from client

YAML configuration name

changeRequestPathAction

Settings

The following table describes the customizable properties available for this action:

Property Type Description DefaultValue
newPath string

Example of usage

The following examples apply this action to any exchanges

Change request path to /hello.

rules:
- filter:
    typeKind: AnyFilter
  actions:
  - typeKind: ChangeRequestPathAction
    newPath: /hello

.NET reference

View definition of ChangeRequestPathAction for .NET integration.

See also

The following actions are related to this action:

Frequently asked questions

Does the host change as well?

No. Only the path is rewritten. To send requests to a different host or port, combine with forwardAction or DNS tricks like spoofDnsAction.

Does the new path include the query string?

Yes. The newPath value replaces both the path and the query string. Append a ?key=value if you need to keep query parameters.

Can I reference captured groups from the path filter?

Yes, when the filter uses regex with capture groups, you can reference them in the new path with positional placeholders like {0}.

What happens to the request body during the rewrite?

It is untouched. Only the URI path is replaced. Headers like Host are preserved.

Learn more about Fluxzy rules