Are you an LLM? You can read better optimized documentation at /en\document\rewrite.md for this page in Markdown format
Rewrite
Rewrite is dedicated to HTTP and HTTPS requests: before a request is sent, its data is modified according to the configured rewrite type. URLs and headers can both be changed today. Every rewrite only applies to plain HTTP requests or to HTTPS requests after decryption.
Rewriting happens before rule matching.
URL rewrite
This type changes the URL of the request.
^http://www\.google\.cn header http://www.google.comDirect-response rewrite
This type returns a redirect response with a 30x status code.
302
^http://example.com 302 https://example.com307
^http://example.com 307 https://example.comreject
- reject — close the connection immediately
- reject-200 — return a 200 response with an empty body
- reject_img — return a 200 response whose body is a one-pixel image
- reject_dict — return a 200 response whose body is the empty JSON object
"{}" - reject_array — return a 200 response whose body is the empty JSON array
"[]"
^http://example.com reject
^http://example.com reject-200
^http://example.com reject-img
^http://example.com reject-dict
^http://example.com reject-arrayHeader rewrite
This type modifies the headers of the request.
^http://example.com header-add Connection keep-alive
^http://example.com header-del Cookie
^http://example.com header-replace User-Agent Unknown