Skip to content

Create rule in the dashboard

  1. Log in to the Cloudflare dashboard and select your account and domain.
  2. Go to Rules > Redirect Rules.
  3. To create a new empty redirect rule, select Create rule. To duplicate an existing rule, select the three dots next to it > Duplicate.
  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.
  6. Under When incoming requests match, select one of the following options:
    • Wildcard pattern: The rule will only apply to traffic matching the wildcard pattern.
      • Request URL: Enter the wildcard pattern using the asterisk (*) character to match multiple requests. For example, https://*.example.com/files/*.
      • Then: Define the URL redirect settings including:
        • Target URL: Enter the target URL, which can be static (for example, https://example.com) or dynamic (for example, https://example.com/${1}/files/${2}). Use wildcard replacement such as ${1} and ${2} to define dynamic target URLs.
        • Status code: Select the status code for the redirect (for example, 301).
        • Preserve query string: Choose whether to keep the query string from the original request.
    • All incoming requests: The rule will apply to all traffic.
    • Custom filter expression: The rule will only apply to traffic matching a custom expression. Define the rule expression to configure which requests should be redirected.
  7. To save and deploy your rule, select Deploy. If you are not ready to deploy your rule, select Save as Draft.