Updated on 2025-07-25 GMT+08:00

Forwarding Rule

Introduction

You can configure forwarding policies to forward requests to different backend server groups based on a wide range of forwarding rules and actions.

Forwarding Rule Types

Advanced forwarding policies support the following types of forwarding rules: domain name, path, HTTP request method, HTTP header, query string, cookie, and CIDR block.

Table 1 Forwarding rules

Forwarding Rule

Description

Domain name

  • Description

    Route requests based on the domain name. You can configure multiple domain names with each consist of at least two labels separated by periods (.). Max total: 100 characters. Max label: 63 characters.

  • Matching rules
    • Exact match and wildcard match: The domain name can contain only letters, digits, and special characters .-?=~_+\^*!$&|()[]. Asterisks (*) and question marks (?) can be used as wildcards. The domain name cannot start or end with a period (.) or contain two consecutive periods (..).
    • Regular expression match: The domain name can contain only letters, digits, and special characters .-?=~_+\^*!$&|()[].
Example
Request URL: https://www.example.com/login.php?locale=en-us=#videos
Domain name in the forwarding rule: www.example.com

Path

  • Description

    Route requests based on paths. You can configure multiple paths in a forwarding policy. A path can contain letters, digits, and special characters: _~';@^-%#$.*+?,=!:|\/()[]{}

  • Matching rules
    • Exact match: The request path is the same as the specified path and must start with a slash (/).
    • Prefix match: The request path starts with the specified path and must start with a slash (/).
    • Regular expression match: The paths are matched using a regular expression.

For more information, see Path Matching Based on Regular Expressions.

Example path:
Request URL: https://www.example.com/login.php?locale=en-us#videos
Path in the forwarding rule: /login.php

Query string

Route requests based on the query string.

A query string consists of a key and one or more values. You need to set the key and values separately.
  • The key can contain only letters, digits, and special characters: !$'()*+,./:;=?@^-_'
  • Multiple values can be configured for a key. The value can contain letters, digits, and special characters: !$'()*+,./:;=?@^-_'. Asterisks (*) and question marks (?) can be used as wildcard characters.
Example
Request URL: https://www.example.com/login.php?locale=en-us#videos
A query string needs to be configured for the forwarding rule:
Key: locale
Value: en-us

HTTP request method

Route requests based on the HTTP method.

  • You can configure multiple request methods in a forwarding policy.
  • The following methods are available: GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS.
Example
GET

HTTP header

Route requests based on the HTTP header.

An HTTP header consists of a key and one or more values. You need to configure the key and values separately.
  • The key can contain only letters, digits, underscores (_), and hyphens (-).
    NOTE:

    The first letter of HTTP request headers User-agent and Connection must be capitalized.

  • Multiple values can be configured for a key. The value can contain only letters, digits, and special characters: !#$%&'()*+,.\/:;<=>?@[]^-_'{|}~. Asterisks (*) and question marks (?) can be used as wildcard characters.
Example
Key: Accept-Language
Value: en-us

CIDR block

Route requests based on source IP addresses from where the requests originate.

Example
192.168.1.0/24 or 2020:50::44/127

Cookie

Route requests based on the cookie.

A cookie consists of a key and a value. You need to configure the key and value separately.

  • A key can contain 1 to 100 characters and cannot start or end with a space. Each key can contain only letters, digits, and special characters: !%'\"()*+,./:;<=>?@[]^-_` {|}~
  • A key can have one value, which can contain 1 to 100 characters.
Example:
Key: cookie_name
Value: cookie_value