Origin URL Rewrite

Last update:2026-03-12 14:20:27

When you configure Origin URL Rewrite in CDN, the CDN will rewrite the origin request URL according to your configured rewrite requirements when fetching content from the origin.

How to Set Origin URL Rewrite

  1. Log in to the CDNetworks Console, and select the appropriate product.
  2. Navigate to the Configuration, locate the domain you wish to configure, click on Edit Configuration on the top or the Edit button to the right of the domain 【产品维护】云安全产品维护公告
  3. Find Origin URL Rewrite, and click Add or Modify.
  4. Configure the following settings based on your needs.

【产品维护】云安全产品维护公告

Apply to URL Pattern (Regex)
Matches client request URLs that meet the specified criteria. Regular expressions are supported, not required to start with /. The platform will automatically prefix the URL with ^https?://[^/]/, e.g., .*.jpg$, indicating that requests for JPG files across all domains associated with this rule will match this policy.

Origin Hostname
Only origin hostnames are supported; origin IP addresses are not supported.

The origin hostname can also be configured in Set Origin and Batch Modify Origin, but the effective priority is lower than this configuration. In other words, when the origin hostname is configured in multiple places, the value configured in Origin URL Rewrite takes effect.

Host Header
When you need to specify the hostname or domain name of the server that the client communicates with, you must configure the Host value, because different hostnames may share the same origin IP, and the origin server uses this value to determine which content to respond. After configuration, when there is a client request carrying Host value, the origin will respond content related to the hostname or domain.
For example, if the value is set at www.cdnetworks.net, an end-user request for www.testdomain.com could send www.cdnetworks.net in the Host header to the origin. Then the origin will respond with www.cdnetworks.net related content.

Host Header can also be configured in Set Origin, Batch Modify Origin and Host Header and Port, but the effective priority of all of them is lower than Origin URL Rewrite. If configured simultaneously, the configuration in Origin URL Rewrite takes effect.

Source URI
Enter the original path to be replaced, that is, the original URI content. Regular expressions are supported.
Make sure that the Source URI and the Target URI must both be configured for the rule to take effect.

Target URI
Enter the modified new path. The new path will replace the original path when fetching content from the origin. Regular expressions are supported.
Make sure that the Source URI and the Target URI must both be configured for the rule to take effect.

Case-Insensitive Match

  • If Yes is selected, CDN will ignore case sensitivity for your defined rule in the URL Pattern when CDN receives a client request URL. For example, if you configure a.jpg, then whether the client request URL is http://domain/a.jpg or http://domain/A.jpg, CDN will rewrite the origin request URL based on the rewrite requirements configured in this rule.
  • If No is selected, the client request will be matched strictly according to the settings in your URL Pattern. For example, if you configure a.jpg, when the client request URL is http://domain/a.jpg, it is considered a successful match and CDN will rewrite the origin request URL based on the rewrite requirements configured in this rule, while http://domain/A.jpg is considered not matched and CDN won’t rewrite the origin request URL.
  • The default value of this field is Yes.

Priority
You can specify the priority level of this rule. The larger the number, the higher the priority. Based on the user’s request, the system matches the rules you have set. If multiple rules apply, the rule with the higher priority will be applied first.

After you have completed setting the configurations, please click OK and then select Next to submit your settings. To minimize any potential disruptions to your production environment, we strongly recommend conducting a Pre-deploy test in a staging environment. This crucial step ensures that your configurations are accurate before they go live. Once you have verified the accuracy of the settings, click Deploy Now to implement them in the live environment. The configurations typically become effective within 3-5 minutes. For comprehensive guidance on pre-deployment testing and to verify the effectiveness of your configurations, please consult the tutorial Deploy the Configurations to Staging Environment for Validation.

Best Practices

When the URL path requested by the user is exactly a.jpg, for example, http://your CDN domain/a.jpg, the CDN will rewrite the origin request URL:

  • Replace the path /test/123.jpg in the original origin request URL with /123.jpg
  • Replace the original origin hostname with www.testdomain.com

That is, the CDN origin request URL will become http://www.testdomain.com/123.jpg.

【产品维护】云安全产品维护公告

Notes

  1. In addition to allowing configuration of the Origin Hostname and URI in the URL, the origin URL Rewrite configuration additionally supports configuration of the Host Header, but this is not mandatory. You can configure it optionally based on your needs. This is intended to provide flexibility, so that you do not need to configure it one by one across multiple configuration locations.
  2. Origin URL Rewrite, Set Origin, Batch Modify Origin and Host Header and Port, all support configuration of the Origin Hostname and Host Header, but Origin URL Rewrite has the highest priority. When configurations exist in multiple places, the platform will give priority to the configuration in Origin URL Rewrite.
Is the content of this document helpful to you?
Yes
I have suggestion
Submitted successfully! Thank you very much for your feedback, we will continue to strive to do better!