The rewrite feature allows you to modify the Uniform Resource Identifiers (URIs) of requests by creating rewrite rules. Based on rewrite rules, you can redirect HTTP requests to the HTTPS versions of web pages. You can also change your accessed URI to the URI of the origin if the two URIs are different. After Dynamic Route for CDN (DCDN) receives a request, DCDN matches the request against the rewrite rules. If a match occurs, DCDN performs a 302 redirect to redirect the request to the specified destination URI. You can create multiple rewrite rules based on your business needs. This topic describes how to configure rewrite rules in the DCDN console.
If you need to modify the requested URI, create a rewrite rule. For example, if a client requests to access
http://example.com over HTTP, you can create a rewrite rule to redirect all the requests for
- Log on to the DCDN 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 Configure in the Actions column.
- In the left-side navigation pane on the details page of the specified domain, click Caching.
- On the Rewrite tab, click Add.
- In the Rewrite dialog box, specify the URI to Be Rewritten, Target URI, and Executing Rules parameters based on your business needs.
Parameter Example Description URI to Be Rewritten
The specified URI can include neither the protocol information nor the domain name. The specified URI must start with a forward slash (/). Perl-compatible regular expressions (PCREs) are supported. Target URI
The specified URI can include neither the protocol information nor the domain name. The specified URI must start with a forward slash (/). Executing Rules Redirect Redirect: When the requested URI matches the current rule, DCDN returns a 302 status code and redirects the request to the destination URI. Break Break: When the requested URI matches the current rule, DCDN returns the content of the destination URI, and stops matching the requested URI against the remaining rules.
- Click OK.
On the Rewrite page, you can click Modify or Delete to manage the rewrite rule.Note You can configure a maximum of 50 rewrite rules for each domain name.
|Example||URI to Be Rewritten||Target URI||Executing Rules||Description|
|Example 1||/hello||/index.html||Redirect||When a client requests the content of
|Example 2||^/hello$||/index.html||Break||When a client requests the content of
|Example 3||^/$||/index.html||Redirect||When a client requests the content of