Rewrite
Add, remove or replace headers and query parameters, change the method, host, path or status, or replace a body on matching traffic.
Rewrite changes real traffic on its way through. Unlike Map Local, the request still reaches the server. WireLens edits what goes out, what comes back, or both.
Add a rule#
- Mac: select a flow and choose Flow ▸ Create Rule ▸ Rewrite… (⇧⌘R). Right-clicking a flow offers Create Rule ▸ Rewrite This URL… and Rewrite Everything on ‹host›…. To start empty, open Tools ▸ Rewrite and click Add Rewrite.
- iPhone and iPad: long-press a host and choose Add Rewrite for Host, or open Tools ▸ Rewrite.
- Android: long-press a host or a request and choose Rewrite…, or open Tools ▸ Rewrite and tap New rule.
What a rule can change#
| Side | Changes |
|---|---|
| Request | Set or remove headers · set or remove query parameters · change the method · change the host (and port) · change the path · replace the body |
| Response | Change the status · set or remove headers · replace the body |
Empty fields are left alone. Every enabled rule that matches applies, top to bottom.
Replacing a body swaps the whole body for the text you give it. When the original arrived compressed, WireLens also fixes the headers that describe it to match the new body. A replacement response body applies to responses small enough to hold in full. A larger response streams through with only the status and header changes.
To change one field inside a JSON body rather than the whole thing, use Scripting: read the body as JSON, change the value, write it back.
Matching#
- URL pattern. Wildcards with
*. A rule with no pattern matches nothing. - Conditions. Narrow a rule further, for example to failing POSTs only. The Mac offers method, GraphQL operation, a request header, status class, content type and a response header. iPhone and iPad offer method, a request header, response status, response
Content-Typeand a response header. Android offers method. - Preview. Type a URL and see what the rule would do to it, without sending anything: Preview on the Mac, Live Preview on iPhone and iPad, Test a URL on Android.
For HTTPS, the host has to be decrypted, since WireLens can only change what it can read. See SSL Proxying. Plain HTTP rules work without it.
On the Mac#
Each rule card has a URL pattern, a Note and Conditions, then Rewrite target: Request or Response, each showing how many changes it holds. Request has Method, Host, Path, Set query, Remove query, Set headers, Remove headers and Body. Response has Status, Set headers, Remove headers and Body. Preview shows the result for a sample URL.
On iPhone and iPad#

A rule has a URL Pattern and Conditions, then Phase: Request or Response. The request side has the Request Line (Method, Host, Path), Query (Set, Remove), Request Headers and Request Body. The response side has Status Override, Response Headers and Response Body. Live Preview applies this rule alone to a Sample URL.
On Android#
The editor has Match (pick a captured request or type a pattern, then Methods) and Changes. Add a change lists what the rule can do:
- Before it is sent: Add a header, Remove a header, Send to another host (add
:portfor another port), Change the path, Add a query parameter, Remove a query parameter, Change the method, Replace the body. - Before the app sees it: Change the status, Add a header, Remove a header, Replace the body.
Each row in the list shows its changes as chips, and how often the rule fired in the traffic on screen.
Rewrite, Map Remote or Scripting?#
- Change where a request goes: Map Remote.
- Change fixed parts of a request or response: Rewrite.
- Change something that depends on the request itself, or edit one JSON field: Scripting.
Settings backups#
Rewrite rules often carry a token in a header or a body. A settings backup made in the Mac app leaves those values out.
Free and Pro#
The free plan includes one Rewrite rule on every platform. Pro removes the limit.
Command line and MCP#
The command line and the MCP server run on the Mac. wirelens ships inside the app and is not on your PATH until you link it once.
wirelens rules rewrite takes one flag per change, and you can repeat them:
wirelens rules rewrite --pattern 'https:// api.example.com/ *' \
--set-header 'X-Debug: 1' \
--remove-header Cookie \
--status 503 \
--response-body '{"error":"maintenance"}' \
--note 'Maintenance drill'
The full set of flags is --method, --host, --path, --set-header, --remove-header, --set-query, --remove-query, --request-body, --status, --set-response-header, --remove-response-header, --response-body and --note. Run wirelens rules rewrite with no --pattern to print them. The MCP tool is add_rewrite.
Something here is unclear, or wrong for your setup? Contact support or write to support@wirelens.app.