Skip to content

Commit cd537fe

Browse files
authored
Reorganize Transform Rules documentation (#1671)
* Move files to new structure * Update content of Transform Rules documentation * Rename Welcome article to Overview
1 parent 3a65e4d commit cd537fe

File tree

18 files changed

+437
-425
lines changed

18 files changed

+437
-425
lines changed

products/rules/src/content/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ pcx-content-type: landing-page
33
order: 1
44
---
55

6-
# Welcome
6+
# Overview
77

8-
With Rules you can manage the following types of rules:
8+
With Rules, you can manage the following types of rules:
99

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).
1111

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.
1313

1414
<Aside type='note' header='Note'>
1515

products/rules/src/content/transform/api/index.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

products/rules/src/content/transform/create-header-modification-rule.md

Lines changed: 0 additions & 108 deletions
This file was deleted.

products/rules/src/content/transform/index.md

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -23,59 +23,12 @@ There are two types of Transform Rules:
2323
To configure Transform Rules in the dashboard, use the **Transform Rules** tab in Rules.
2424

2525
<ButtonGroup>
26-
<Button type="primary" href="/transform/create-url-rewrite-rule">Create a URL Rewrite Rule</Button>
27-
<Button type="primary" href="/transform/create-header-modification-rule">Create a Header Modification Rule</Button>
28-
<Button type="secondary" href="/transform/use-cases">Examples</Button>
26+
<Button type="primary" href="/transform/url-rewrite/create-dashboard">Create a URL Rewrite Rule</Button>
27+
<Button type="primary" href="/transform/request-header-modification/create-dashboard">Create a Request Header Modification Rule</Button>
2928
</ButtonGroup>
3029

3130
---
3231

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-
<Aside type='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-
7932
## Availability
8033

8134
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
9952

10053
To get started building your own Transform Rules, see:
10154

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)
10457

105-
You can also [create Transform Rules via API](/transform/api).
58+
You can also create Transform Rules via API:
10659

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)
10862

10963
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.

products/rules/src/content/transform/manage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ The **Transform Rules** dashboard interface lets you:
2222

2323
In the **Transform Rules** tab you can:
2424

25-
* [Create a URL Rewrite Rule](/transform/create-url-rewrite-rule)
26-
* [Create an HTTP Request Header Modification Rule](/transform/create-header-modification-rule)
25+
* [Create a URL Rewrite Rule](/transform/url-rewrite/create-dashboard)
26+
* [Create an HTTP Request Header Modification Rule](/transform/request-header-modification/create-dashboard)
2727

2828
See each linked section for details on creating each rule type.
2929

products/rules/src/content/transform/api/header-modification-rule.md renamed to products/rules/src/content/transform/request-header-modification/create-api.md

Lines changed: 6 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
---
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
45
order: 2
56
---
67

78
# Create an HTTP Request Header Modification Rule via API
89

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.
1011

1112
When creating an HTTP Request Header Modification Rule via API, make sure you:
1213

1314
* 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)
1516
* Deploy the rule to the `http_request_late_transform` phase at the zone level
1617

17-
## Create an HTTP Request Header Modification Rule
18+
---
1819

1920
Follow this workflow to create an HTTP Request Header Modification Rule for a given zone via API:
2021

@@ -257,87 +258,3 @@ header: Response
257258

258259
</div>
259260
</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-
<Aside type='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:
330-
331-
```json
332-
"action_parameters": {
333-
"headers": {
334-
"<HEADER_NAME_1>": {
335-
"operation": "set",
336-
"value": "<HEADER_VALUE_1>"
337-
},
338-
"<HEADER_NAME_2>": {
339-
"operation": "remove"
340-
}
341-
}
342-
}
343-
```

0 commit comments

Comments
 (0)