Surge 使用手册
搜索文档…
重写请求头
这个功能目前仅在 Beta 版中提供。
在请求被转发到服务器前,Surge 可以修改请求头。
例子:
1
[Header Rewrite]
2
^http://example.com header-add DNT 1
3
^http://example.com header-del Cookie
4
^http://example.com header-replace User-Agent Unknown
Copied!
每条规则包含 4 个部分:URL 正则表达式、行为类型、请求头里的哪个部分以及变量。T

header-add

像请求头中附加一条属性。
例子:
1
[Header Rewrite]
2
^http://example.com header-add DNT 1
3
4
Before:
5
GET /index.html HTTP/1.1
6
Host: example.com
7
Connection: keep-alive
8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
9
Accept-Language: en-us
10
Accept-Encoding: gzip, deflate
11
12
After:
13
GET /index.html HTTP/1.1
14
Host: example.com
15
Connection: keep-alive
16
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
17
Accept-Language: en-us
18
Accept-Encoding: gzip, deflate
19
DNT: 1
Copied!

header-del

删除请求头中的某条属性。
例子:
1
[Header Rewrite]
2
^http://example.com header-del DNT
3
4
Before:
5
GET /index.html HTTP/1.1
6
Host: example.com
7
Connection: keep-alive
8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
9
Accept-Language: en-us
10
Accept-Encoding: gzip, deflate
11
DNT: 1
12
13
After:
14
GET /index.html HTTP/1.1
15
Host: example.com
16
Connection: keep-alive
17
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
18
Accept-Language: en-us
19
Accept-Encoding: gzip, deflate
Copied!

header-replace

替换请求头中某条属性的值。
例子:
1
[Header Rewrite]
2
^http://example.com header-replace DNT 1
3
4
Before:
5
GET /index.html HTTP/1.1
6
Host: example.com
7
Connection: keep-alive
8
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
9
Accept-Language: en-us
10
Accept-Encoding: gzip, deflate
11
DNT: 0
12
13
After:
14
GET /index.html HTTP/1.1
15
Host: example.com
16
Connection: keep-alive
17
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30
18
Accept-Language: en-us
19
Accept-Encoding: gzip, deflate
20
DNT: 1
Copied!
如果你想添加或替换请求头中的任意一个参数,你可以将 header-add 和 header-del 组合起来用。
1
[Header Rewrite]
2
^http://example.com header-del DNT
3
^http://example.com header-add DNT 1
Copied!
最近更新 1yr ago