百度智能云

All Product Document

          CDN

          Configure URI Rewriting

          Overview

          When you need to modify the actual URI to a URI that matches the origin server, you can redirect the URI 302 to the target URI by customizing the URI rewriting configuration.

          Considerations

          • By default, the URI does not contain any parameters.
          • For a single domain name, you can add up to 10 rewriting rules.
          • Priority: Matches the rules according to the configuration order. If the match is successful, it is finished. The priority of the URIs configured earlier is higher than that configured later.

          URI Rewriting Configuration

          1. Log in to CDN Management Console to enter the “Content Distribution Network (CDN) page.
          2. Click Domain Name - Management on the left navbar.
          3. Enter the domain name management page, and click Management in the operation column of the target domain name.
          4. Enter the "CDN Domain Name Details" page and select the Cache configuration tab in the navbar at the top of the page.
          5. Click Add rewriting rule in URI rewriting configuration.

          image.png

          1. Complete the rewriting rules in the pop-up URI rewriting configuration box.

          image.png

          Description of configuration items
          URI to be rewritten Does not contain http(s):// header and domain name.
          Can match the parameters, e.g., you can only modify the URI that contains specific parameters.
          Supports the regular expression and capture, such as (/[^?]+)\?c=1
          Target URI Does not contain http(s):// header and domain name.
          The final URI generated must start with /.
          Support the capture, such as ${1}/test.
          If the target URI does not contain ?, it contains the original parameter. If it contains ?, the parameter after ? is used to replace the original parameter.
          For example, the access URI is /a?c=1.
          ? The URI to be rewritten is /a and the target URI is /b, so the modified URI is /b?c=1.
          ? The URI to be rewritten is /a and the target URI is /b?, so the modified URI is /b.
          ? The URI to be rewrittehn is /a and the target URI is /b?d=1, so the modified URI is /b?d=1.
          Execution rules? Redirect: If the requested URI matches the current rule, this request is redirected by 302 to the target URI.
          ? Break: If the requested URI matches the current rule, it does not match the remaining rule after the current rule is executed.
          1. Click OK to complete the rule configuration.
          Previous
          Set the Error Page Customization
          Next
          Configure Ignoring Paramters