Alibaba Cloud CDN allows you to rewrite URL parameters in requests before the requests are redirected to origin servers. You can ignore, add, delete, retain, and modify parameters.
Background information
A URL parameter is a
name-value
pair that follows a question mark (?
) in a URL. If the URL contains multiple parameters, the parameters are separated by ampersands (&
).In some cases, a URL also contains a number sign (
#
) and characters that follow the number sign (#
). The number sign (#
) represents a position on a web page, and the character on the right is the identifier of the position. The number sign (#
) leads a browser to a specific spot on a web page and does not affect the server. Therefore, the number sign can be ignored in back-to-origin requests. After the browser reads the character after the number sign#
, the browser points to the specific spot. For example, inhttp://www.example.com/index.html#segment
,#segment
represents thesegment
spot of theindex.html
page. After the URL is opened in a browser, the browser points to the spot.
Parameter priority
After you enable parameter rewrite, the query strings in origin URLs are rewritten. You can configure one or more rewrite rules. Rewrite rules take effect in the following order: Add > Delete > Reserve Only > Modify. If you configure multiple rewrite rules for the same parameter, only the rewrite rule that has the highest priority takes effect.
If you turn on Ignore Parameters, only the Add rewrite rule takes effect.
Usage notes
Parameter rewrite rules may conflict with the enhance break
rule in Back-to-origin URL Rewrite and the Ignore Parameters feature. Make sure that the rules do not conflict with each other. The latest configuration takes effect.
Impact on cache keys
Parameter rewrite is performed on Alibaba Cloud CDN points of presence (POPs) for origin fetch. Internal Alibaba Cloud CDN links are not affected. The cache keys remain unchanged.
The Ignore Parameters feature is performed on Alibaba Cloud CDN POPs for edge processing. Internal Alibaba Cloud CDN links are affected. The cache keys are changed.
Procedure
Log on to the Alibaba Cloud CDN console.
In the left-side navigation pane, click Domain Names.
On the Domain Names page, find the domain name that you want to manage and click Manage in the Actions column.
In the left-side navigation pane of the domain name, click Origin Fetch.
Click the Parameter Rewrite tab.
Turn on Feature Switch.
In the Rewrite Parameters dialog box, configure the required parameters.
You can configure different types of rewrite rules or specify multiple parameters in a rewrite rule based on your business requirements. For more information, see Configuration examples.
Click OK to apply the rewrite rule.
To modify a rewrite rule, find the rule on the Parameter Rewrite tab and click Modify in the Actions column.
Configuration examples
Example 1: Ignore all URL parameters
Parameter
Example
Ignore Parameters
On
Add
None
Delete
None
Reserve Only
None
Modify
None
Expected result
Original request:
http://example.com/index.html?code1=1&code2=2&code3=3
Final request:
http://example.com/index.html
Example 2: Retain specified parameters
Parameter
Example
Ignore Parameters
On
Add
None
Delete
None
Reserve Only
code2
Modify
None
Rule Condition
Do not use conditions
Expected result
Original request:
http://example.com/index.html?code1=1&code2=2&code3=3
Final request:
http://example.com/index.html?code2=2
Example 3: Add, delete, and modify specific parameters
Parameter
Example
Ignore Parameters
On
Add
code4=4
Delete
code2
Reserve Only
None
Modify
code3=0
Rule Condition
Do not use conditions
Expected result
Original request:
http://example.com/index.html?code1=1&code2=2&code3=3
Final request:
http://example.com/index.html?code4=4