Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,59 +1,4 @@
---
title: Create a rule in the dashboard
pcx_content_type: how-to
sidebar:
order: 2
head:
- tag: title
content: Create a rewrite URL rule in the dashboard
---

import { Render } from "~/components";

Refer to the [Rules examples gallery](/rules/transform/examples/?operation=Rewrite+URL) for examples of rule definitions.

To create a rule:

1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/), and select your account and website.

2. Go to **Rules** > **Overview**.

3. Select **Create rule** > **URL Rewrite Rule**.

4. (Optional) Select one of the rule templates that address common use cases. Then, review and adjust the proposed rule configuration.

5. Enter a descriptive name for the rule in **Rule name**.

![The rewrite URL rule creation page in the Cloudflare dashboard.](~/assets/images/rules/transform/create-url-rewrite-rule.png)

6. Under **If incoming requests match**, select one of the following options:

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

- **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/).

:::note
Check the [fields and functions](/rules/transform/url-rewrite/reference/fields-functions/) you can use in filter expressions of rewrite URL rules.
:::

- **All incoming requests**: The rule will apply to all traffic.

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:

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

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

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

For more information, refer to [URL rewrite parameters](/rules/transform/url-rewrite/reference/parameters/).

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

9. To save and deploy your rule, select **Deploy**. If you are not ready to deploy your rule, select **Save as Draft**.

<Render file="rules-creation-dash-dns-popup" />

---\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 ![The rewrite URL rule creation page in the Cloudflare dashboard.](~/assets/images/rules/transform/create-url-rewrite-rule.png)\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" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bllchmbrs Same issue here as seen before, with "\n" characters in the proposed changes instead of real line breaks.

## Wildcard pattern parameters

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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: URL rewrite parameters
description: Learn about static and dynamic URL rewrite parameters in Cloudflare, including syntax for URI path and query string rewrites, and wildcard matching.
pcx_content_type: reference
sidebar:
order: 2
Expand All @@ -13,7 +14,6 @@ Static and dynamic URL rewrites have different parameters:
A URL rewrite with wildcard patterns is a simplified interface in the Cloudflare dashboard for creating dynamic URL rewrites with [wildcard matching and replacement](#wildcard-matching-and-replacement).

The maximum length of all parameter values in a URL rewrite (combined) is 4,096 characters. For example, you could provide a static value (or an expression) for the URI path with 2,048 characters and a static value (or expression) for the query string with 2,048 characters.

## API information

### Static URL rewrites
Expand Down
Loading