If the parameters in the original request URL differ from what your origin server requires, you can use the Parameter Rewrite feature to rewrite the parameters in the origin fetch request URL. This feature lets you add, delete, reserve, modify, or ignore parameters.
URL parameter format
-
URL parameters are one or more
name/valuepairs appended to a URL after a?character, in the formatname=value. Multiple parameters are separated by an&. -
A URL can also contain a
#character and the text that follows it. The#directs a browser to a specific location on a web page.For example, in
http://www.example.com/index.html#segment, the#segmentpart points to thesegmentlocation on theindex.htmlpage. After the browser loads the page, it automatically scrolls to that location.
Operation priority
-
Parameter Rewrite lets you configure multiple rewrite operations for the query parameters in an origin fetch request URL. The priority order is Add > Delete > Reserve Only > Modify. When different operations target the same parameter, only the one with the highest priority takes effect.
-
If Ignore Parameters is enabled, Add is the only other operation that takes effect.
Conflicts with other features
Parameter Rewrite may conflict with the enhance break rule of Rewrite Origin Fetch URL and the Ignore Parameters feature. If a conflict occurs, the last-configured feature takes precedence.
Impact on the cache key
-
The Parameter Rewrite feature runs on the origin fetch POP. It does not affect CDN internal routing and does not rewrite the cache key.
-
The Ignore Parameters feature runs on the edge node. It affects CDN internal routing and rewrites the cache key.
If a configuration uses a rule condition from the rules engine, the condition's priority determines the execution order, overriding the feature's configuration order.
Procedure
-
Log on to the CDN console.
-
In the left navigation pane, click Domain Names.
-
On the Domain Names page, find the target domain name and click Manage in the Actions column.
-
In the left-side navigation pane for the domain name, click Origin Fetch.
-
Click the Parameter Rewrite tab.
-
Turn on the Feature Switch.
-
Configure the parameters to be rewritten.
Configure the rewrite operations as needed. You can also add multiple parameters in the text box for each operation type. For more information, see Configuration examples.
-
Click OK to apply the configuration.
You can also click Modify on the Parameter Rewrite page to modify existing rules.
Configuration examples
-
Example 1: Ignore all parameters
Parameter
Value
Ignore Parameters
Enabled
Add
None
Delete
None
Reserve Only
None
Modify
None
Rule Condition
Not used
Result
Original request:
http://example.com/index.html?code1=1&code2=2&code3=3Rewritten origin fetch request:
http://example.com/index.html -
Example 2: Retain a specific parameter
Parameter
Value
Ignore Parameters
Disabled
Add
None
Delete
None
Reserve Only
code2
Modify
None
Rule Condition
Not used
Result
Original request:
http://example.com/index.html?code1=1&code2=2&code3=3Rewritten origin fetch request:
http://example.com/index.html?code2=2 -
Example 3: Add, delete, and modify parameters
Parameter
Value
Ignore Parameters
Disabled
Add
code4=4
Delete
code2
Reserve Only
None
Modify
code3=0
Rule Condition
Not used
Result
Original request:
http://example.com/index.html?code1=1&code2=2&code3=3Rewritten origin fetch request:
http://example.com/index.html?code1=1&code3=0&code4=4