URL Rewrite

Chute can rewrite the request's URL with different methods, or reject certain requests by URL.

Only one rule could be applied for one single request.

Notice: A plain HTTP request is processed only when it reaches Chute through its HTTP proxy; plain HTTP that arrives through the TUN interface is forwarded untouched. Chute Android sends all traffic through TUN unless System HTTP Proxy is turned on in Settings, which hands apps Chute's HTTP proxy (Android 10 and later; off by default). An HTTPS request is processed only when its host is decrypted with MitM.

Example:

[URL Rewrite]
^http://www\.google\.cn http://www.google.com header
^http://amazon\.cn https://z.cn 302
^http://ad\.com/ad\.png _ reject
^http://tracker\.com/event _ reject-200
^http://ad\.com/pixel _ reject-img
^http://api\.example\.com/block _ reject-dict
^http://api\.example\.com/list _ reject-array
^http://ad\.com/beacon _ reject-tinygif

The rewrite rule consists 3 parts: regular expression, replacement and type. The parts are separated by whitespace, and the first word that starts with #, ; or // begins a comment that runs to the end of the line; this section has no quotes. See Comment.

For the reject types (reject, reject-200, reject-img, reject-dict, reject-array, reject-tinygif), a two-token shorthand <pattern> reject without the _ placeholder is also accepted. The shorthand also takes Shadowrocket's reject-drop and reject-no-drop, both answered as reject, and reject-video, answered as reject-200; these three are accepted in the shorthand only, not as the type of a three-token line. A two-token line whose second token is not a reject keyword is read as a header-mode rewrite to that URL: ^http://a\.com http://b.com is the same as ^http://a\.com http://b.com header. Mind the spelling of the reject keywords — reject200 is not one, so ^http://ad\.com reject200 is read as a header-mode rewrite to reject200. That replacement is neither an absolute URL nor an absolute path, so at request time the rewrite is refused with a warning in the log and the request is forwarded unchanged: neither rejected nor rewritten.

Answers Chute generates itself — Map Local, a script's response, and the answers and error page of URL Rewrite and the REJECT policies — follow HTTP: the answer to a HEAD request is the header alone, with the Content-Length a GET would get, and an answer with status 204, 205 or 304 carries neither a body nor a Content-Length.

Header Mode

Chute will modify the request header and redirect the request to another host if necessary. The client will not notice this rewrite action. (This mode corresponds to Surge's "Map Remote".)

The "Host" field in request header will be modified to match the new URL.

[URL Rewrite]
^http://www\.google\.cn http://www.google.com header

The replacement may also be a path-only form like /new/path. In that case only the request line is rewritten to the new path, and the request is still sent to the same host. Only a replacement that starts with a scheme and :// is read as a URL, so a path whose query string carries one, such as /go?to=http://example.com/, is still a path-only replacement.

When the destination cannot be rewritten in place — for example rewriting a plain HTTP request to an https:// URL, rewriting an HTTPS request (with MitM enabled) to a different origin, or matching a follow-up request on an already-established plain HTTP keep-alive connection with a rule that names a different host — Chute automatically falls back to answering the client with a 307 redirect to the new URL instead of a transparent header rewrite.

302 Mode

Chute will simply return a 302 redirect response. HTTPS requests can be redirected if MitM for the hostname is enabled.

[URL Rewrite]
^http://amazon\.cn https://z.cn 302

307 Mode

Chute will simply return a 307 temporary redirect response. HTTPS requests can be redirected if MitM for the hostname is enabled.

[URL Rewrite]
^http://amazon\.cn https://z.cn 307

Reject Mode

Reject the request if the pattern is matched. The replacement parameter will be ignored. Returns an HTTP 503 response. HTTPS requests will be rejected if MitM for the hostname is enabled.

[URL Rewrite]
^http://ad\.com/ad\.png _ reject

Reject-200 Mode

Reject the request with an HTTP 200 OK status and zero-length body. Useful for silently blocking tracking requests without triggering error handling.

[URL Rewrite]
^http://tracker\.com/event _ reject-200

Reject-Img Mode

Reject the request by returning a 1x1 white GIF image (HTTP 200 OK). Useful for blocking ad images without causing broken image placeholders.

[URL Rewrite]
^http://ad\.com/pixel _ reject-img

Reject-Dict Mode

Reject the request by returning an empty JSON object {} (HTTP 200 OK). Useful for blocking API calls that expect a JSON response.

[URL Rewrite]
^http://api\.example\.com/block _ reject-dict

Reject-Array Mode

Reject the request by returning an empty JSON array [] (HTTP 200 OK). Useful for blocking API calls that expect a list.

[URL Rewrite]
^http://api\.example\.com/list _ reject-array

Reject-TinyGIF Mode

Reject the request by returning a 1×1 GIF image (HTTP 200 OK) — Surge's spelling of the same answer as reject-img.

[URL Rewrite]
^http://ad\.com/beacon _ reject-tinygif
S. Smart Rabbit LLC © All Rights Reserved            updated 2026-09-25 00:02:29

results matching ""

    No results matching ""