cloudflare
Cloudflare与阿里云OSS的带宽联盟
api 刷新缓存
cloudflare 通过api修改301规则
利用 workers反向代理
本文档使用 MrDoc 发布
-
+
首页
cloudflare 通过api修改301规则
# 通过 API 创建重定向规则 https://developers.cloudflare.com/rules/url-forwarding/single-redirects/create-api/ # 获取 301 规则id ``` curl -X GET "https://api.cloudflare.com/client/v4/zones/34cb36574012588596d37e35646a74f6/rulesets" -H "Authorization: Bearer {api token}" { "result": [ { "description": "Created by the Cloudflare security team, this ruleset is designed to provide protection for free zones", "id": "77454fe2d30c4220b5701f6fdfb893ba", "kind": "managed", "last_updated": "2024-08-01T17:37:10.825759Z", "name": "Cloudflare Managed Free Ruleset", "phase": "http_request_firewall_managed", "source": "firewall_managed", "version": "57" }, { "description": "Created by the Cloudflare security team, this ruleset provides normalization on the URL path", "id": "70339d97bdb34195bbf054b1ebe81f76", "kind": "managed", "last_updated": "2024-08-01T17:37:11.538019Z", "name": "Cloudflare Normalization Ruleset", "phase": "http_request_sanitize", "version": "6" }, { "description": "Rules maintained by bots team that can run for all plans", "id": "3e677e63d4e9479382576f3fa66279e7", "kind": "managed", "last_updated": "2024-11-26T17:15:34.314543Z", "name": "Cloudflare Bot Management rules for all plans", "phase": "http_request_sbfm", "source": "firewall_managed", "version": "8" }, { "description": "Automatic mitigation of HTTP-based DDoS attacks. Cloudflare routinely adds signatures to address new attack vectors. Additional configuration allows you to customize the sensitivity of each rule and the performed mitigation action.", "id": "4d21379b4f9f4bb088e0729962c8b3cf", "kind": "managed", "last_updated": "2024-12-04T16:25:03.620149Z", "name": "DDoS L7 ruleset", "phase": "ddos_l7", "version": "2596" }, { "description": "", ## 这个就是 301 重定向 "id": "1756d6560f6e40189680a7cbee970902", ## 这个是规则id "kind": "zone", "last_updated": "2024-12-05T03:41:46.597751Z", "name": "Redirect rules ruleset", "phase": "http_request_dynamic_redirect", "version": "1" } ], "success": true, "errors": [], "messages": [] } ``` ## update 规则 ``` curl --request PUT \ --url https://api.cloudflare.com/client/v4/zones/e0bd8bcfc4513a3d391e12535621a6de/rulesets/{rulesetId} \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer {api token}' \ --data '{ "rules": [ { "action": "redirect", "expression": "http.host wildcard \"xxx.live\"", "description": "301", "action_parameters": { "from_value": { "target_url": { "value": "https://xxx.live" }, "status_code": 301, "preserve_query_string": true } } } ] }' ```
admin
2024年12月5日 12:26
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码