If you need to modify the parameters in URLs of the access requests sent to the origin, you can create rules to rewrite parameters. This topic describes how to create parameter rewrite rules in the CDN console.

Background information

When the parameters in a request URL are inconsistent with the parameters that you want to send to the origin, you can create parameter rewrite rules. These rules allow you to ignore, add, delete, retain, and modify the parameters.

Procedure

  1. Log on to the Alibaba Cloud CDN console.
  2. In the left-side navigation pane, click Domain Names.
  3. On the Domain Names page, find the target domain name and click Manage.
  4. In the left-side navigation pane of the specified domain name, click Back-to-origin.
  5. Click the Parameter Rewrite tab.
  6. On the Parameter Rewrite tab, turn on Rewrite Parameters.
    1
  7. You can configure different types of rewrite rules or press Enter to specify multiple parameters for a rewrite rule based on your business needs.
    2
  8. Click OK to apply and run the rewrite rules.

    To modify the existing rewrite rules, click Modify on the Parameter Rewrite tab.

    3
    Notice

    When you configure parameter rewrite rules, note the following:

    • The priorities of the following rewrite rules are in descending order: the Add rule, the Delete rule, the Reserve Only rule, and the Modify rule.
    • The Ignore Parameters feature and the Reserve Only rule are mutually exclusive. Do not configure them at the same time to avoid feature conflicts.
    • If you turn on Ignore Parameters and leave the Reserve Only field empty, all parameters included in the original request URLs will be ignored. However, the Add rule and the Delete rule still take effect because they have higher priorities.
    • If you enter parameters in the Reserve Only field and turn off Ignore Parameters, only the specified parameters are retained in the original request URLs. However, the Add rule and the Delete rule still take effect because they have higher priorities.
    Note

    The parameter rewrite feature conflicts with other features as follows:

    • The Parameter Rewrite feature rewrites the parameters in request URLs, which may conflict with a URI Rewrite rule whose flag is set to enhance_break. If you configure both features, make sure that no conflicts exist.
    • The Parameter Rewrite feature rewrites parameters in request URLs, which may conflict with the settings of the Retain Parameters or Ignore Parameters feature on the Domain Names > Optimization page. If you configure the three features at the same time, make sure that no conflicts exist.
    • The Parameter Rewrite feature functions at the CDN nodes that communicate with the origin, which does not affect the internal links of CDN or rewrite the Cache Key. The Retain Parameters or Ignore Parameters feature functions at the CDN edge nodes, which affects the internal links of CDN and rewrites the Cache Key.

Example

Example 1

Ignore Parameters Enabled
Add None
Delete None
Reserve Only None
Modify None
Description Original request: http://domain.com/index.html?code1=1&code2=2&code3=3

Rewritten request: http://domain.com/index.html

Example 2

Ignore Parameters Disabled
Add None
Delete None
Reserve Only code2
Modify None
Description Original request: http://domain.com/index.html?code1=1&code2=2&code3=3

Rewritten request: http://domain.com/index.html?code2=2

Example 3

Ignore Parameters Disabled
Add code4=4
Delete code2
Reserve Only None
Modify code3=0
Description Original request: http://domain.com/index.html?code1=1&code2=2&code3=3

Rewritten request: http://domain.com/index.html?code1=1&code3=0&code4=4