Updated on 2026-11-02 GMT+08:00

Redirecting Requests

Redirection Overview

When using static website hosting, you can configure redirection to redirect specific or all requests.

If the structure, address, or file name extension of a website is changed, users will fail to access the website using the old address (such as the address saved in the folder of favorites), and the 404 error message is returned. In this case, you can configure redirection for the website to redirect user access requests to a specified page rather than a 404 error page.

Typical use cases for request redirection include:

  • Redirecting all requests to another website
  • Defining specific redirection rules to redirect selected requests

This section describes three redirection scenarios:

  • Redirecting all requests to another bucket or URL: When configuring static website hosting for a bucket, set Hosting Type to Redirect requests.
  • Redirecting requests for objects with a specific prefix or for a specific object to another object or URL: When configuring static website hosting for a bucket, set Hosting Type to Host a static website and configure the redirection rule.
  • Redirecting requests for the default homepage of a static website to another object in the same bucket or to a URL:
    1. When configuring static website hosting for a bucket, set Hosting Type to Host a static website and specify the name of the static webpage file in the bucket's root directory as the default homepage.
    2. Add the WebsiteRedirectLocation metadata to the webpage file in the root directory.

Prerequisites

Web page files required for static website hosting have been uploaded to the specified bucket.

The static website files hosted in the bucket are accessible to all users.

Static web page files in the Archive or Deep Archive storage class have been restored. For more information, see Restoring Archive or Deep Archive Objects.

Redirecting All Requests to Another Bucket or URL

To redirect all requests to another bucket or URL, set Hosting Type to Redirect requests when configuring static website hosting for the bucket.

You can configure this setting using OBS Console, APIs, or SDKs, but not using OBS Browser+ or obsutil.

Redirecting Requests for Objects with a Specific Prefix or for a Specific Object to Another Object or URL

To redirect requests for objects with a specific prefix or for a specific object to another object or URL, set Hosting Type to Host a static website and configure a redirection rule when configuring static website hosting for a bucket.

You can configure this setting using OBS Console, APIs, or SDKs, but not using OBS Browser+ or obsutil.

Redirect Default Homepage Requests to Another Object in the Same Bucket or to a URL

To redirect requests for the default homepage of a static website to another object in the same bucket or to a URL, configure static website hosting for the bucket as follows: set Hosting Type to Host a static website, set the default homepage to a static web page file in the bucket's root directory, and add the WebsiteRedirectLocation metadata to that file.

You can configure this setting using OBS Console, APIs, or SDKs, but not using OBS Browser+ or obsutil.