Skip to content
Rules
Visit Rules on GitHub
Set theme to dark (⇧+D)

Create a URL Rewrite Rule in the dashboard

Create URL Rewrite Rules in the Transform Rules tab under Rules. See URL rewrite examples for examples of rule definitions.

Do the following:

  1. Log in to the Cloudflare dashboard.

  2. Select the Websites tab and choose the site for which you want to create a new URL Rewrite Rule.

  3. Select Rules > Transform Rules.

    Transform Rules tab

  4. Click Create transform rule > Rewrite URL.

    Create Transform Rule page

  5. In the page that displays, enter a descriptive name for the rule in Rule name. The rule name in this example is Welcome GB Users.

  6. Under When incoming requests match, use the Field drop-down list to choose an HTTP property. For each request, the value of the property you choose for Field is compared to the value you specify for Value.

    Selecting a field in the Expression Builder

  7. Select a comparison operator in the Operator drop-down list.

    Selecting an operator in the Expression Builder

    The Expression Editor area displays a text-only version of your expression. For more information on the Expression Editor, see Edit rule expressions in the Firewall documentation.

  8. Specify the value to match. If the value is an enumeration, the Value control will be a drop-down list. Otherwise, it will be a text input. In this example the value United Kingdom is set using the Country drop-down list.

    Entering a field value in the Expression Builder

  9. Add any other filters to the rule expression. The example defines an additional filter for the URI Path, which must be equal to /welcome.html.

  10. To define the action for your URL Rewrite Rule, select one of the available options displayed as radio buttons and then a value from the drop-down list, depending on the action.

    In this example, the Static action tells Cloudflare to rewrite the original path to the provided path, /welcome-gb.html.

    Static path rewrite for GB users

    If you do not want to change the value of a component of the original request (for example, the URL query string), choose Preserve as the action for that component.

  11. To save and deploy your rule, click Deploy. If you are not ready to deploy your rule, click Save as Draft.

After you choose an option, you return to the Transform Rules dashboard interface, which displays your new rule:

Rules List displaying the new GB rule

If you choose to deploy your URL Rewrite Rule, the new rule will be enabled. If you save the rule as a draft, the new rule will be disabled.