|
1 | | ---- |
2 | | -title: Create a rule in the dashboard |
3 | | -pcx_content_type: how-to |
4 | | -sidebar: |
5 | | - order: 2 |
6 | | -head: |
7 | | - - tag: title |
8 | | - content: Create a rewrite URL rule in the dashboard |
9 | | ---- |
10 | | - |
11 | | -import { Render } from "~/components"; |
12 | | - |
13 | | -Refer to the [Rules examples gallery](/rules/transform/examples/?operation=Rewrite+URL) for examples of rule definitions. |
14 | | - |
15 | | -To create a rule: |
16 | | - |
17 | | -1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/), and select your account and website. |
18 | | - |
19 | | -2. Go to **Rules** > **Overview**. |
20 | | - |
21 | | -3. Select **Create rule** > **URL Rewrite Rule**. |
22 | | - |
23 | | -4. (Optional) Select one of the rule templates that address common use cases. Then, review and adjust the proposed rule configuration. |
24 | | - |
25 | | -5. Enter a descriptive name for the rule in **Rule name**. |
26 | | - |
27 | | -  |
28 | | - |
29 | | -6. Under **If incoming requests match**, select one of the following options: |
30 | | - |
31 | | - - **Wildcard pattern**: The rule will only apply to traffic matching the wildcard pattern in **Request URL**. Refer to [Wildcard pattern parameters](#wildcard-pattern-parameters) for details. |
32 | | - |
33 | | - - **Custom filter expression**: The rule will only apply to traffic matching a custom expression. Define the [rule expression](/ruleset-engine/rules-language/expressions/edit-expressions/) to configure which requests should be rewritten. Use either the Expression Builder or the Expression Editor to define the custom expression. For more information, refer to [Edit expressions in the dashboard](/ruleset-engine/rules-language/expressions/edit-expressions/). |
34 | | - |
35 | | - :::note |
36 | | - Check the [fields and functions](/rules/transform/url-rewrite/reference/fields-functions/) you can use in filter expressions of rewrite URL rules. |
37 | | - ::: |
38 | | - |
39 | | - - **All incoming requests**: The rule will apply to all traffic. |
40 | | - |
41 | | -7. (Optional) Define the action for your rewrite URL rule by selecting one of the available options displayed as radio buttons, and then a value from the drop-down list, depending on the action: |
42 | | - |
43 | | - - If you select **Rewrite to** > _Static_, enter the string that will replace the original URL path (or query string). For example, enter `welcome-gb.html` to rewrite the original URL path to `/welcome-gb.html`. |
44 | | - |
45 | | - - If you select **Rewrite to** > _Dynamic_, enter a [rewrite expression](/rules/transform/url-rewrite/reference/fields-functions/#rewrite-expressions) that defines the dynamic URL rewrite to perform. |
46 | | - |
47 | | - - If you do not want to change the value of a component of the original request (the URL path or the URL query string), choose _Preserve_ for that component. |
48 | | - |
49 | | - For more information, refer to [URL rewrite parameters](/rules/transform/url-rewrite/reference/parameters/). |
50 | | - |
51 | | -8. (Optional) Under **Place at**, define where to place the rule in the rules list: first rule in the list, last rule in the list, or in a custom position (after a given rule). |
52 | | - |
53 | | -9. To save and deploy your rule, select **Deploy**. If you are not ready to deploy your rule, select **Save as Draft**. |
54 | | - |
55 | | - <Render file="rules-creation-dash-dns-popup" /> |
56 | | - |
| 1 | +---\ntitle: Create a rule in the dashboard\npcx_content_type: how-to\ndescription: Learn how to create URL rewrite rules in the Cloudflare dashboard using wildcard patterns. Configure dynamic paths and queries for efficient URL management.\nsidebar:\n order: 2\nhead:\n - tag: title\n content: Create a rewrite URL rule in the dashboard\n---\n\nimport { Render } from "~/components";\n\nRefer to the [Rules examples gallery](/rules/transform/examples/?operation=Rewrite+URL) for examples of rule definitions.\n\nTo create a rule:\n\n1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/), and select your account and website.\n\n2. Go to **Rules** > **Overview**.\n\n3. Select **Create rule** > **URL Rewrite Rule**.\n\n4. (Optional) Select one of the rule templates that address common use cases. Then, review and adjust the proposed rule configuration.\n\n5. Enter a descriptive name for the rule in **Rule name**.\n\n \n\n6. Under **If incoming requests match**, select one of the following options:\n\n - **Wildcard pattern**: The rule will only apply to traffic matching the wildcard pattern in **Request URL**. Refer to [Wildcard pattern parameters](#wildcard-pattern-parameters) for details.\n\n - **Custom filter expression**: The rule will only apply to traffic matching a custom expression. Define the [rule expression](/ruleset-engine/rules-language/expressions/edit-expressions/) to configure which requests should be rewritten. Use either the Expression Builder or the Expression Editor to define the custom expression. For more information, refer to [Edit expressions in the dashboard](/ruleset-engine/rules-language/expressions/edit-expressions/).\n\n :::note\n Check the [fields and functions](/rules/transform/url-rewrite/reference/fields-functions/) you can use in filter expressions of rewrite URL rules.\n :::\n\n - **All incoming requests**: The rule will apply to all traffic.\n\n7. (Optional) Define the action for your rewrite URL rule by selecting one of the available options displayed as radio buttons, and then a value from the drop-down list, depending on the action:\n\n - If you select **Rewrite to** > _Static_, enter the string that will replace the original URL path (or query string). For example, enter `welcome-gb.html` to rewrite the original URL path to `/welcome-gb.html`.\n\n - If you select **Rewrite to** > _Dynamic_, enter a [rewrite expression](/rules/transform/url-rewrite/reference/fields-functions/#rewrite-expressions) that defines the dynamic URL rewrite to perform.\n\n - If you do not want to change the value of a component of the original request (the URL path or the URL query string), choose _Preserve_ for that component.\n\n For more information, refer to [URL rewrite parameters](/rules/transform/url-rewrite/reference/parameters/).\n\n8. (Optional) Under **Place at**, define where to place the rule in the rules list: first rule in the list, last rule in the list, or in a custom position (after a given rule).\n\n9. To save and deploy your rule, select **Deploy**. If you are not ready to deploy your rule, select **Save as Draft**.\n\n <Render file="rules-creation-dash-dns-popup" /> |
57 | 2 | ## Wildcard pattern parameters |
58 | 3 |
|
59 | 4 | The Cloudflare dashboard offers a simplified user interface for creating URL rewrites based on wildcard matching and replacement. When you select **Wildcard pattern**, you will have the following parameters available: |
|
0 commit comments