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.
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
The rewrite rule consists 3 parts: regular expression, replacement and type.
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.
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
You can't redirect to an URL with HTTPS scheme. And you can't redirect a HTTPS request.
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 HTTP 403 Forbidden. 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 transparent 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