After you configure redirection-based back-to-origin rules for a bucket, if an error occurs when a requester accesses the bucket, OSS redirects the request to the origin specified by the redirection-based back-to-origin rules. You can use this feature to redirect requests for objects and develop various services based on redirection.


  • Number of rules

    You can configure up to 20 back-to-origin rules for a bucket. The rules are sequentially matched with requests based on the values of RuleNumber. If a request matches a rule, the subsequent rules are not matched. OSS determines whether a request matches a back-to-origin rule based on whether the request meets the conditions specified in the rule. OSS does not check whether the requested object can be obtained from the origin.

  • Back-to-origin URL

    You cannot use an internal endpoint as the back-to-origin URL.


The redirection-based back-to-origin feature enables OSS to return a redirection response and an HTTP status code 3xx based on the specified back-to-origin conditions and redirection configurations. The following figure shows how redirection-based back-to-origin works.


  • Seamless data migration from other data sources to OSS

    When you use the redirection-based back-to-origin feature to asynchronously migrate data from your client to OSS, OSS returns a 302 redirection request by using URL rewrite for the data that is not migrated to OSS. Then, your client can read data from the data source based on the Location value in the 302 redirection request.

  • Page redirection

    For example, you can use redirection-based back-to-origin to hide objects whose names contain a specified prefix and return a specific page to requesters.

  • Page redirection for 404 or 500 errors

    You can use redirection-based back-to-origin to redirect requests to a preset error page once a 404 or 500 error occurs. This prevents OSS from exposing system errors to requesters.

Use the OSS console

If an error occurs when your visitor accesses a bucket, you can specify the URL of the object in the origin and back-to-origin conditions to redirect the access to the origin. For example, you have a bucket named example that is located in the China (Hangzhou) region. You want a requester to be redirected to obtain the required object in the examplefolder folder from when the requester accesses the object in the examplefolder folder of the bucket root folder but the object does not exist.

  1. Log on to the OSS console.
  2. Click Buckets, and then click the name of the target bucket.
  3. In the left-side navigation pane, choose Basic Settings > Back-to-Origin.
  4. Click Configure. Click Create Rule.
  5. In the Create Rule panel, set Mode to Redirection.
  6. Configure Prerequisite and Origin URL.
    Parameter Description
    • Select HTTP Status Code, and then set HTTP Status Code to 404.

      Valid values of HTTP status codes: 400 to 599. For more information about the error information of various HTTP status codes, see Common errors and troubleshooting.

    • Select File Name Prefix, and then set File Name Prefix to examplefolder/.
      Note File Name Prefix and File Name Suffix are optional. When you configure multiple back-to-origin rules, you must set different file name prefixes or suffixes to differentiate back-to-origin rules.
    Origin URL Select Add Prefix or Suffix. Set the first column to https and the second column to Leave another column empty.
  7. Click OK.
    Access process after the back-to-origin rule is configured:
    1. A requester accesses for the first time.
    2. If the examplefolder/example.txt object does not exist in examplebucket , OSS returns HTTP status code 301 to the requester and provides for redirection.
    3. The requester accesses
    The following table describes the parameters you can configure for different scenarios.
    Scenario Parameter
    An object name prefix is different from the prefix of the name of the object in the origin. Select Replace or Delete File Prefix, and set the third column of Origin URL. OSS replaces the File Name Prefix content with the content in the third column of Origin URL.

    You can configure this item after you configure File Name Prefix.

    Transfer the query string included in a request from OSS to the origin. Select Transfer queryString.
    An HTTP redirect code must be replaced. The default HTTP redirect code of a redirection rule is 301. You can select 302 or 307 from the Redirection Code drop-down list.
    A redirect request is from Alibaba Cloud CDN. Specify whether to select Source from Alibaba Cloud CDN.

    When the redirect request is from Alibaba Cloud CDN: If you select Source from Alibaba Cloud CDN, CDN automatically follows redirection rules and then obtains content. If you do not select Source from Alibaba Cloud CDN, CDN automatically returns the URL for redirection to the client.