If the storage path of resources on your origin server changes but the requested URL remains unchanged, you can configure redirect rules on Edge Security Acceleration (ESA) points of presence (POPs) to match the origin path and redirect the request URL to the destination URL. This helps reduce requests to the origin and improve access performance of clients.
How a redirect rule works
The following list describes how a redirect rule works:
After you configure a redirect rule on an ESA POP, initiate a resource access request on a client.
The ESA POP returns a redirect status code such as 301 or 302 to the client and carries the destination URL in the HTTP response header.
After receiving the response, the client initiates a request to the URL in the Location header of the ESA POP to complete resource access.
Supported redirect status codes and scenarios
301
Description: Moved Permanently
Processing method: GET requests remain unchanged. Requests that use other request methods may be changed to GET.
Scenario: Requested resources are permanently moved to the new URL that is specified by the Location header. In this case, search engines update the URL to the web page.
302
Description: Found
Processing method: GET requests remain unchanged. Requests that use other request methods may be changed to GET.
Scenario: A web page is temporarily inaccessible. In this case, search engines do not update the URL to the web page.
303
Description: See Other
Processing method: GET requests remain unchanged. Requests that use other request methods are changed to GET. The message body is dropped.
Scenario: This status code is used to redirect PUT and POST requests to prevent repeated redirections that are caused by a page refresh.
307
Description: Temporary Redirect
Processing method: The request method and message body remain unchanged.
Scenario: A web page is temporarily inaccessible. If the website supports requests that use request methods other than GET, status code 307 is returned instead of status code 302.
308
Description: Permanent Redirect
Processing method: The request method and message body remain unchanged.
Scenario: Resources are permanently migrated. The request method and message body must remain unchanged on the client. This status code applies to scenarios requiring semantic consistency, such as website refactoring and API migration.
Configure a redirect rule
After you add a redirect rule and initiate a resource access request, ESA matches and executes rules in sequence based on rule priorities and returns the corresponding results.
In the ESA console, choose Websites and click the name of the website you want to manage.
In the left-side navigation pane, choose .
Click Create Rule, and fill in the Rule Name.
In the If Requests Match... area, specify the conditions for matching incoming requests. For more information about how to configure a rule, see Rules.
In the URL Redirect area, select Static as Redirect Type, specify URL, and select a value from the Status Code drop-down list.

Redirect Type
Valid values: Static and Dynamic.
Static: To redirect a request to a fixed URL, select Static and set the destination URL to a fixed string. For example, set URL to
https://test.example.com/image/1.jpg?test=123.Dynamic: To dynamically modify the original URL, select Dynamic and set the destination URL to an expression. For example, set Expression to
concat("https://www.example.com", http.request.uri.path). The value indicates that the hostname in the requested URL is replaced with a new domain name and the path in the URL remains unchanged.
Status Code
The response code that you want to use to indicate URL redirection. Valid values: 301, 302, 303, 307, and 308. Default value: 301. For more information, see Supported redirect status codes and scenarios.
Retain Query String
Specifies whether to include the query parameters of the original request in the destination URL. By default, the query parameters of the original request are not included after URL redirection.
After you enable Retain Query String:
If a request URL contains the query string, the query string overwrites the query string in the redirect URL.
If the query string is not included in the URL of the request, the query string in the redirect URL is used.
For more information, see Configuration examples.
Click OK.
Configuration examples
Configuration examples when Redirect Type is Static
Example 1
Query string included in requests: No
Query string included in the redirect URL: Yes
Retain Query String: Enabled/Disabled
Sample request URL:
http://test.example.com/1.jpgSample redirect URL:
http://test.example.com/image/1.jpg?test=123Sample Location header:
http://test.example.com/image/1.jpg?test=123Note: If the sample request URL does not contain a query string, the sample Location header retains the query string of the sample redirect URL, regardless of whether Retain Query String is enabled.
Example 2
Query string included in requests: Yes
Query string included in the redirect URL: Yes
Retain Query String: Enabled
Sample request URL:
http://test.example.com/1.jpg?test=321Sample redirect URL:
http://test.example.com/image/1.jpg?test=123Sample Location header:
http://test.example.com/image/1.jpg?test=321Note: If Retain Query String is enabled, only the query string of the sample request URL is retained, and the query string of the sample redirect URL is ignored.
Example 3
Query string included in requests: Yes
Query string included in the redirect URL: Yes
Retain Query String: Disabled
Sample request URL:
http://test.example.com/1.jpg?test=321Sample redirect URL:
http://test.example.com/image/1.jpg?test=123Sample Location header:
http://test.example.com/image/1.jpg?test=123Note: If Retain Query String is disabled, only the query string of the sample redirect URL is retained, and the query string of the sample request URL is ignored.
Example 4
Query string included in requests: Yes
Query string included in the redirect URL: No
Retain Query String: Enabled
Sample request URL:
http://test.example.com/1.jpg?test=321Sample redirect URL:
http://test.example.com/image/1.jpgSample Location header:
http://test.example.com/image/1.jpg?test=321Note: If Retain Query String is enabled, the query string of the sample request URL is automatically added to the sample redirect URL, regardless of whether the sample redirect URL contains a query string.
Example 5
Query string included in requests: Yes
Query string included in the redirect URL: No
Retain Query String: Disabled
Sample request URL:
http://test.example.com/1.jpg?test=321Sample redirect URL:
http://test.example.com/image/1.jpgSample Location header:
http://test.example.com/image/1.jpgNote: If Retain Query String is disabled, the query string of the sample request URL is discarded, and only the sample redirect URL is returned.
Configuration examples when Redirect Type is Dynamic
Example 1
Retain Query String: Disabled
Sample request URL:
https://test.example.com/image/1.jpg?test=123Function expression:
concat("https://www.example.com", http.request.uri.path)Sample Location header:
https://www.example.com/image/1.jpgNote:
If Retain Query String is disabled, only the path part (
/image/1.jpg) of the sample request URL is retained, and the query string (?test=123) is ignored.The function expression only concatenates the domain name and path but does not process the query string.
Example 2
Retain Query String: Enabled
Sample request URL:
https://test.example.com/image/1.jpg?test=123Function expression:
concat("https://www.example.com", http.request.uri.path)Sample Location header:
https://www.example.com/image/1.jpg?test=123Note:
If Retain Query String is enabled, the query string of the sample request URL is automatically added to the sample redirect URL regardless of whether the function expression explicitly processes the query string.
The function expression only concatenates the path. The system automatically adds the query string based on the configuration.
Retain Query String | Sample request URL | Function expression | Sample Location header |
Disabled | https://test.example.com/image/1.jpg?test=123 | concat("https://www.example.com", http.request.uri.path) | https://www.example.com/image/1.jpg |
Enabled | https://test.example.com/image/1.jpg?test=123 | concat("https://www.example.com", http.request.uri.path) | https://www.example.com/image/1.jpg?test=123 |
Availability
Redirect rules | Entrance | Pro | Premium | Enterprise |
Number of redirect rules | 10 | 25 | 50 | 125 |