A rewrite rule is a condition (when it applies) plus one or more actions (what to do). Rules run in the tunnel without modifying the app under test. They must be saved and enabled, and the global Rewrite gate must be on. Verify with a new request.
Simple mode
Swipe a Recent Requests row → New rewrite (host and path prefilled), or tap + in the rewrite list. Choose when it applies, then one of six intents:
| Intent | Effect |
|---|---|
| Edit Header | Add, change, or delete a request or response header. |
| Edit Body | Replace text in the request or response body. |
| Mock response | Skip the origin and return custom content. |
| Block request | Empty response, empty JSON object/array, or empty image. |
| Redirect | Send the client to another URL (for example production → staging). |
| Local file | Serve a file on the device as the response (Map Local). |
Multiple Simple-mode conditions are combined with AND. For OR, create another rule with the same action. Expert mode is for multiple actions, parentheses, and regular expressions.
Expert DSL
The first token of an action (^ replace/insert, ~ delete, or an @ verb) selects what to do; @req.* / @rsp.* selects where; quoted strings hold values. Use ASCII " quotes — curly quotes fail silently.
| Condition | Meaning |
|---|---|
@req.host | Request host |
@req.api | Path |
@req.url / @req.query / @req.method | Full URL, query string, HTTP method |
@req.header["Name"] / @req.bodyText | Request header or body |
@rsp.status / @rsp.bodyText | Response status or body |
Operators include ==, !=, CONTAINS, BEGINSWITH, ENDSWITH, LIKE, MATCHES, IN. Logic uses &&, ||, !, and parentheses.
| Action | Example |
|---|---|
^ replace/insert | ^@req.header["X-Debug"] "1" |
~ delete | ~@req.header["Authorization"] |
@mock | @mock "{\"ok\":true}" |
@reject / @reject-img / @reject-dict / @reject-array | @reject-array |
@redirect or @301…@308 | @redirect 307 "https://staging/x" |
@map-local | @map-local "/shared/mock.json" |
@break | @break |
URL and method. ^@req.host, ^@req.api, and ^@req.method cannot change the URL or method. Executable actions cover headers, bodies, status, mock, reject, redirect, Map Local, and break.