You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: products/rules/src/content/index.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,13 @@ pcx-content-type: landing-page
3
3
order: 1
4
4
---
5
5
6
-
# Welcome
6
+
# Overview
7
7
8
-
With Rules you can manage the following types of rules:
8
+
With Rules, you can manage the following types of rules:
9
9
10
-
-**Page Rules**- Allow you to control which Cloudflare settings trigger on a given URL. Learn about Page Rules in the [Support KB](https://support.cloudflare.com/hc/articles/218411427).
10
+
***Page Rules**— Allow you to control which Cloudflare settings trigger on a given URL. Learn about Page Rules in the [Support KB](https://support.cloudflare.com/hc/articles/218411427).
11
11
12
-
-[**Transform Rules**](/transform)- Allow you to make adjustments to incoming requests at the edge before they go through any other Cloudflare products.
12
+
*[**Transform Rules**](/transform)— Allow you to make adjustments to incoming requests at the edge before they go through any other Cloudflare products.
<Buttontype="primary"href="/transform/url-rewrite/create-dashboard">Create a URL Rewrite Rule</Button>
27
+
<Buttontype="primary"href="/transform/request-header-modification/create-dashboard">Create a Request Header Modification Rule</Button>
29
28
</ButtonGroup>
30
29
31
30
---
32
31
33
-
## URL Rewrite Rules
34
-
35
-
A URL Rewrite Rule can perform a **static rewrite** or a **dynamic rewrite**. Static rewrites replace a given part of a request URL (path or query string) with a static string. Dynamic rewrites support more advanced scenarios where you use an [expression](https://developers.cloudflare.com/firewall/cf-firewall-rules/fields-and-expressions) to define the resulting path or query string.
36
-
37
-
To create a URL Rewrite Rule in the dashboard, see [Create a URL Rewrite Rule in the dashboard](/transform/create-url-rewrite-rule).
38
-
39
-
To create a URL Rewrite Rule via API, see [Create a URL Rewrite Rule via API](/transform/api/url-rewrite-rule).
40
-
41
-
### Rewrites and redirects
42
-
43
-
You can manipulate the URL of a request through different operations, namely through rewrites and redirects.
44
-
45
-
A **rewrite** is a server-side operation that occurs before a web server has fully processed a request. A rewrite is not visible to website visitors, since the URL displayed in the browser does not change.
46
-
47
-
A **redirect** is a client-side operation that occurs after the web server has loaded the initial URL. In this case, a website visitor can see the URL changing when the redirect occurs.
48
-
49
-
You can configure URL Rewrite Rules in the dashboard to perform rewrites at the edge without reaching your web server. URL Rewrite Rules run in the `http_request_transform` phase of Cloudflare's request handling workflow. For more information on phases, check the [Ruleset Engine](https://developers.cloudflare.com/firewall/cf-rulesets) documentation.
50
-
51
-
Check [Configuring URL forwarding or redirects with Cloudflare Page Rules](https://support.cloudflare.com/hc/articles/200172286) in the Support KB to learn more about configuring redirects.
52
-
53
-
---
54
-
55
-
## HTTP Request Header Modification Rules
56
-
57
-
You can manipulate the headers of incoming HTTP requests through HTTP Request Header Modification Rules. Through these rules you can:
58
-
59
-
* Set the value of an HTTP request header to a literal string value, overwriting its previous value or adding a new header to the request.
60
-
* Set the value of an HTTP request header according to an expression, overwriting its previous value or adding a new header to the request.
61
-
* Remove an HTTP request header from the request (remove all headers with the provided name).
62
-
63
-
<Asidetype='warning'header='Important'>
64
-
65
-
* You cannot modify or remove HTTP request headers whose name starts with `cf-` or `x-cf-` except for the `cf-connecting-ip` HTTP request header, which you can remove.
66
-
67
-
* If you modify the value of an existing HTTP request header using an expression that evaluates to an empty string (`""`) or an undefined value, the HTTP request header is **removed**.
68
-
69
-
</Aside>
70
-
71
-
HTTP Request Header Modification Rules run in the `http_request_late_transform` phase of Cloudflare's request handling workflow. For more information on phases, see [Phases](https://developers.cloudflare.com/firewall/cf-rulesets#phases) in the Ruleset Engine documentation.
72
-
73
-
To create an HTTP Request Header Modification Rule in the dashboard, see [Create an HTTP Request Header Modification Rule in the dashboard](/transform/create-header-modification-rule).
74
-
75
-
To create an HTTP Request Header Modification Rule via API, see [Create an HTTP Request Header Modification Rule via API](/transform/api/header-modification-rule).
76
-
77
-
---
78
-
79
32
## Availability
80
33
81
34
Cloudflare Transform Rules are available to all customers. Keep in mind that support for regular expressions is based on your plan type.
@@ -99,11 +52,12 @@ A Cloudflare user must have the [Firewall role](https://support.cloudflare.com/h
99
52
100
53
To get started building your own Transform Rules, see:
101
54
102
-
*[Create a URL Rewrite Rule](/transform/create-url-rewrite-rule)
103
-
*[Create an HTTP Request Header Modification Rule](/transform/create-header-modification-rule)
55
+
*[Create a URL Rewrite Rule in the dashboard](/transform/url-rewrite/create-dashboard)
56
+
*[Create an HTTP Request Header Modification Rule in the dashboard](/transform/request-header-modification/create-dashboard)
104
57
105
-
You can also [create Transform Rules via API](/transform/api).
58
+
You can also create Transform Rules via API:
106
59
107
-
For common Transform Rule scenarios, see [Common use cases](/transform/use-cases).
60
+
*[Create a URL Rewrite Rule via API](/transform/url-rewrite/create-api)
61
+
*[Create an HTTP Request Header Modification Rule via API](/transform/request-header-modification/create-api)
108
62
109
63
Check [Firewall Rules language](https://developers.cloudflare.com/firewall/cf-firewall-language) for more information on building expressions for Transform Rules, since the language is the same as the Firewall Rules language.
Copy file name to clipboardExpand all lines: products/rules/src/content/transform/request-header-modification/create-api.md
+6-89Lines changed: 6 additions & 89 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,21 @@
1
1
---
2
-
title: Create a Request Header Modification Rule
3
-
pcx-content-type: interim
2
+
title: Create a rule via API
3
+
pcx-content-type: how-to
4
+
type: overview
4
5
order: 2
5
6
---
6
7
7
8
# Create an HTTP Request Header Modification Rule via API
8
9
9
-
Use the [Rulesets API](https://developers.cloudflare.com/firewall/cf-rulesets/rulesets-api) to create HTTP Request Header Modification Rules via API. Define the header modification configuration in the `action_parameters` field. See [Common use cases](/transform/use-cases#http-request-header-modification-examples) for example rule definitions.
10
+
Use the [Rulesets API](https://developers.cloudflare.com/firewall/cf-rulesets/rulesets-api) to create HTTP Request Header Modification Rules via API. Define the header modification configuration in the `action_parameters` field. See [Request header modification examples](/transform/request-header-modification/examples) for examples of rule definitions.
10
11
11
12
When creating an HTTP Request Header Modification Rule via API, make sure you:
12
13
13
14
* Set the rule action to `rewrite`
14
-
* Define the [header modification parameters](#header-modification-parameters) in the `action_parameters` field according to the operation to perform (set or remove header)
15
+
* Define the [header modification parameters](/transform/request-header-modification/reference/parameters) in the `action_parameters` field according to the operation to perform (set or remove header)
15
16
* Deploy the rule to the `http_request_late_transform` phase at the zone level
16
17
17
-
## Create an HTTP Request Header Modification Rule
18
+
---
18
19
19
20
Follow this workflow to create an HTTP Request Header Modification Rule for a given zone via API:
20
21
@@ -257,87 +258,3 @@ header: Response
257
258
258
259
</div>
259
260
</details>
260
-
261
-
---
262
-
263
-
## Header modification parameters
264
-
265
-
To set an HTTP request header, set the following parameters in the `action_parameters` field:
266
-
267
-
***operation**: `set`
268
-
* Include one of the following parameters to define a static or dynamic value:
269
-
270
-
***value**: Specifies a static value for the HTTP request header.
271
-
***expression**: Specifies the expression that defines a value for the HTTP request header.
272
-
273
-
To remove an HTTP request header, set the following parameter in the `action_parameters` field:
274
-
275
-
***operation**: `remove`
276
-
277
-
### Static header value parameters
278
-
279
-
The full syntax of the `action_parameters` field to define a static HTTP request header value is the following:
280
-
281
-
```json
282
-
"action_parameters": {
283
-
"headers": {
284
-
"<HEADER_NAME>": {
285
-
"operation": "set",
286
-
"value": "<URI_PATH_VALUE>"
287
-
}
288
-
}
289
-
}
290
-
```
291
-
292
-
### Dynamic header value parameters
293
-
294
-
The full syntax of the `action_parameters` field to define a dynamic HTTP request header value using an expression is the following:
295
-
296
-
```json
297
-
"action_parameters": {
298
-
"headers": {
299
-
"<HEADER_NAME>": {
300
-
"operation": "set",
301
-
"expression": "<EXPRESSION>"
302
-
}
303
-
}
304
-
}
305
-
```
306
-
307
-
<Asidetype='note'>
308
-
309
-
Check the [available fields and functions](/transform/create-header-modification-rule#available-fields-and-functions) you can use in an expression.
310
-
311
-
</Aside>
312
-
313
-
### Header removal parameters
314
-
315
-
The full syntax of the `action_parameters` field to remove an HTTP request header is the following:
316
-
317
-
```json
318
-
"action_parameters": {
319
-
"headers": {
320
-
"<HEADER_NAME>": {
321
-
"operation": "remove"
322
-
}
323
-
}
324
-
}
325
-
```
326
-
327
-
### Different header modifications in the same rule
328
-
329
-
The same rule can modify different HTTP request headers using different operations (set or remove a header). For example, a single rule can set the value of a header and remove a different header. The syntax of such a rule could be the following:
0 commit comments