All Products
Search
Document Center

Edge Security Acceleration:Request redirects

Last Updated:Oct 14, 2026

If origin resource paths change while request URLs remain the same, configure redirect rules on Edge Security Acceleration (ESA) POPs to redirect clients to the correct destination. This reduces back-to-origin requests and improves access performance.

How it works

image

The redirect process:

  1. A client requests a resource.

  2. The ESA POP matches the request against redirect rules. On a match, it returns a redirect status code (e.g., 301 or 302) with the destination URL in the Location response header.

  3. The client follows the Location header and requests the resource from the new URL.

Status codes and scenarios

Status code

Meaning

Method handling

Common scenarios

301

Moved Permanently

GET requests remain unchanged. Other methods may change to GET.

The resource permanently moved to a new URL. Search engines update their indexes.

302

Found

GET requests remain unchanged. Other methods may change to GET.

The resource is temporarily at a different URL. Search engines retain the original link.

303

See Other

GET requests remain unchanged. Other methods are forced to GET, and the request body is discarded.

Redirect after PUT or POST to prevent duplicate submissions on refresh.

307

Temporary Redirect

Method and request body remain unchanged.

Temporary redirect. Prefer over 302 when your site uses non-GET methods.

308

Permanent Redirect

Method and request body remain unchanged.

Permanent redirect that preserves the HTTP method and request body. Use for API migrations or site refactoring requiring method consistency.

Important

If you need to redirect API calls or non-GET requests (such as POST or PUT) while preserving the request method and body, use status code 307 (temporary) or 308 (permanent). Status codes 301 and 302 may convert non-GET requests to GET, resulting in data loss.

Avoid configuring redirects on high-traffic upload paths (such as /api/upload). For such paths, consider splitting them into a dedicated domain or intercepting requests via WAF to prevent abnormal back-to-origin traffic caused by redirects.

Create a redirect rule

ESA evaluates rules in priority order and applies the first match.

  1. In the ESA console, choose Site Management. In the Website column, click the target site.

  2. In the navigation pane on the left, choose Rules > Redirect Rules. Click Create Rule.

  3. On the Add Redirect Rule page, configure the following settings and click OK:

    • Enter a Rule Name.

    • In the If requests match... section, define the request conditions to match. For more information, see Components of a rule expression.

    • URL Redirect:

      Parameter

      Type

      Description

      Redirect Type

      Static

      Redirect to a fixed URL. For example, set URL to https://test.example.com/image/1.jpg?test=123.

      Dynamic

      Construct the destination URL dynamically with an expression. For example, to replace the hostname in the request URL while keeping the original path, set Expression to concat("https://www.example.com", http.request.uri.path). Use a valid expression built with supported functions. Entering a plain string containing variables directly will cause a save failure.

      Common dynamic expression patterns:

      • Preserve original path (non-www to www, HTTP to HTTPS) — Use concat("https://target-domain.com", http.request.uri.path) to concatenate the target domain with the original request path. Use this pattern when you need to retain the path during redirect.

      • Remove or replace a path prefix — Use concat("https://img.example.com", regex_replace(http.request.uri.path, "^/data", "")) to remove the /data prefix from the original path and redirect to the new domain. Combine regex_replace with concat to transform the path.

      Status Code

      The HTTP status code returned for the redirect. Valid values: 301 (default), 302, 303, 307, and 308. For details, see Status codes and scenarios.

      Retain Query String

      Whether to carry the original request's query string to the destination URL. Disabled by default (the original query string is dropped).

      When Retain Query String is enabled:

      • If the original request has a query string, it overrides the redirect URL's query string.

      • If the original request has no query string, the redirect URL's query string is preserved.

      For configuration examples, see Configuration examples.

Configuration examples

Static redirect examples

Scenario 1: Request has no query string, redirect URL has a query string

  • Request contains query string: No

  • Configured redirect URL contains query string: Yes

  • Preserve query string: Enabled or disabled

  • Sample request URL: http://test.example.com/1.jpg

  • Configured redirect URL: http://test.example.com/image/1.jpg?test=123

  • Actual redirect Location: http://test.example.com/image/1.jpg?test=123

  • Notes: No query string in the original request, so the configured URL's query string is used regardless of the Preserve query string setting.

Scenario 2: Both URLs have query strings, Preserve query string enabled

  • Request contains query string: Yes

  • Configured redirect URL contains query string: Yes

  • Preserve query string: Enabled

  • Sample request URL: http://test.example.com/1.jpg?test=321

  • Configured redirect URL: http://test.example.com/image/1.jpg?test=123

  • Actual redirect Location: http://test.example.com/image/1.jpg?test=321

  • Notes: With Preserve query string enabled, only the original request's query string is kept; the configured URL's query parameters are discarded.

Scenario 3: Both URLs have query strings, Preserve query string disabled

  • Request contains query string: Yes

  • Configured redirect URL contains query string: Yes

  • Preserve query string: Disabled

  • Sample request URL: http://test.example.com/1.jpg?test=321

  • Configured redirect URL: http://test.example.com/image/1.jpg?test=123

  • Actual redirect Location: http://test.example.com/image/1.jpg?test=123

  • Notes: With Preserve query string disabled, only the configured URL's query string is kept; the original request's query parameters are discarded.

Scenario 4: Request has a query string, redirect URL does not, Preserve query string enabled

  • Request contains query string: Yes

  • Configured redirect URL contains query string: No

  • Preserve query string: Enabled

  • Sample request URL: http://test.example.com/1.jpg?test=321

  • Configured redirect URL: http://test.example.com/image/1.jpg

  • Actual redirect Location: http://test.example.com/image/1.jpg?test=321

  • Notes: With Preserve query string enabled, the original query string is appended to the configured URL even if it has no query parameters.

Scenario 5: Request has a query string, redirect URL does not, Preserve query string disabled

  • Request contains query string: Yes

  • Configured redirect URL contains query string: No

  • Preserve query string: Disabled

  • Sample request URL: http://test.example.com/1.jpg?test=321

  • Configured redirect URL: http://test.example.com/image/1.jpg

  • Actual redirect Location: http://test.example.com/image/1.jpg

  • Notes: With Preserve query string disabled, the original query string is discarded and only the configured URL is returned.

Dynamic redirect examples

Scenario 1: Preserve query string disabled

  • Preserve query string: Disabled

  • Sample request URL: https://test.example.com/image/1.jpg?test=123

  • Expression: concat("https://www.example.com", http.request.uri.path)

  • Actual redirect Location: https://www.example.com/image/1.jpg

  • Notes:

    • With Preserve query string disabled, the path (/image/1.jpg) is kept and the query string (?test=123) is dropped.

    • The expression concatenates hostname and path only; query parameters are not handled.

Scenario 2: Preserve query string enabled

  • Preserve query string: Enabled

  • Sample request URL: https://test.example.com/image/1.jpg?test=123

  • Expression: concat("https://www.example.com", http.request.uri.path)

  • Actual redirect Location: https://www.example.com/image/1.jpg?test=123

  • Notes:

    • With Preserve query string enabled, the original query string is appended to the generated URL even if the expression does not handle query parameters.

    • The expression handles path concatenation only; the system appends the query string per configuration.

Scenario 3: wildcard_replace function, Preserve query string enabled

  • Preserve query string: Enabled

  • Sample request URL: https://www.example.com/image-flower-20250816-1.html?src=cdn

  • Expression: wildcard_replace(http.request.full_uri, "https://www.example.com/image-*", "https://www.example.com/${1}")

  • Actual redirect Location: https://www.example.com/flower-20250816-1.html?src=cdn

  • Notes:

    • With Preserve query string enabled, the system appends the original query string (e.g., ?src=cdn) to the destination URL.

    • The expression handles path rewriting only; the system passes through the query string per configuration.

Scenario 4: wildcard_replace function, Preserve query string disabled

  • Preserve query string: Disabled

  • Sample request URL: https://www.example.com/index.html?place=garden&date=20250816

  • Expression: wildcard_replace(http.request.full_uri, "https://www.example.com/index.html?place=garden&date=*", "https://www.example.com/flower-${1}-1.html")

  • Actual redirect Location: https://www.example.com/flower-20250816-1.html

  • Notes:

    • With Preserve query string disabled, the destination URL is built entirely from the expression. Original parameters (e.g., place=garden) are used only for matching; * captures the value after date and substitutes it as ${1}.

    • The final URL excludes the original query parameters.

FAQ

Plan support

Feature

Entrance

Pro

Premium

Enterprise

Number of rules

10

25

50

125

Related documentation

Rule-related features vary in effective priority, reentrancy, and effective granularity. For details, see Characteristics of rule-based features.