Updated on 2024-04-16 GMT+08:00

Configuring Redirection

You can redirect all requests for a bucket to another bucket or URL by configuring redirection rules.

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.

Procedure

  1. In the bucket list, click the bucket you want to operate to go to the Objects page.
  2. In the navigation pane, choose Overview.
  3. In the Basic Configurations area, click Static Website Hosting. 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 Status.
  6. Set Hosting Type to Redirect requests. In the text box of Redirect To, enter the bucket's access domain name or URL.
  7. Click OK.
  8. In the bucket list, click the bucket to which requests for the static website are redirected.
  9. (Optional) If the static website files in the bucket are not accessible to everyone, perform this step. If they are already accessible to everyone, skip this step.

    To grant required permissions, see Granting Anonymous Users Permission to Access Objects.

    If the bucket contains only static website files, configure the Object Read-Only policy for the bucket, so that all files in it are publicly accessible.

    1. Choose Permissions > Bucket Policies.
    2. Click Create.
    3. Configure bucket policy information.
      Table 1 Parameters for configuring a public read policy

      Parameter

      Description

      Configuration method

      Visual Editor and JSON are available. Choose Visual Editor here. For details, see Creating a Custom Bucket Policy (JSON View).

      Policy Name

      Enter a custom policy name.

      Policy content

      Effect

      Select Allow.

      Principals

      Select All accounts.

      Resources

      • Select Specified objects.
      • Set the resource path to * (indicating all objects in the bucket).

      Actions

      • Choose Use a template.
      • Select Object Read-Only.
    4. Click Create. The bucket policy is created.

  10. 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.