Configuring Redirection

You can configure static website hosting by redirecting all requests for a bucket to another bucket or URL.

Prerequisites

Web page files of the static website have been uploaded to a bucket.

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

If the web page files are in the Archive storage class, restore them first. For more information, see Restoring an Archive File Stored in OBS.

After static website hosting is configured, when anonymous users directly access the bucket's access domain name (for example, bucketname.obs.cn-north-4.myhuaweicloud.com), the access domain name (for example, bucketname.obs.cn-north-4.myhuaweicloud.com/index.html) of the static website file, or the access domain name (for example, bucketname.obs-website.cn-north-4.myhuaweicloud.com) of the static website, the static website file will be downloaded to their local PC. If you want to preview the website content, but not to download static website files, when accessing a static website, bind a user-defined domain name to the bucket that hosts the static website and then use the bound domain name for access. If CDN is used, you can also refer to Why Is My .html Static Website File Directly Downloaded When I Access It? if needed.

Procedure

  1. In the navigation pane on the left of OBS Console, choose Object Storage.
  2. In the bucket list, click a bucket name, and then the Overview page of the bucket is displayed.
  3. In the Basic Configurations area, click the Static Website Hosting label. The Static Website Hosting page is displayed.

    Alternatively, you can choose Basic Configurations > Static Website Hosting from the navigation pane on the left.

  4. Click Configure Static Website Hosting. The Configure Static Website Hosting dialog box is displayed.
  5. Enable it by turning on the status switch.
  6. Set Hosting By to Redirection. See Figure 1 for details. Enter a bucket access domain name or URL in the text box of Redirect To.

    Figure 1 Configuring redirection

  7. Click OK.
  8. In the bucket list, click the bucket to which requests for the static website are redirected.
  9. Verification: Input the access domain name of the bucket in the web browser and press Enter. The bucket or URL to which requests are redirected will be displayed.

    In some conditions, you may need to clear the browser cache before the expected results are displayed.