You can configure static website hosting for a bucket by using the OSS console and access the static website by using the custom domain name bound to the bucket.

Background information

By specifying the default homepage and default 404 page of a bucket, you can have resources in the bucket displayed as static web pages.
  • When you configure static website hosting, the default homepage is required whereas the default 404 page is optional.
  • We recommend that you bind a custom domain name to your bucket and use this custom domain name to access static websites. For more information about how to bind a custom domain name, see Bind a custom domain name.
    Notice For security reasons, starting from August 13, 2018 for China regions, and September 25, 2019 for regions outside China, when you access OSS web page objects whose MIME type is text or HTML and whose name extension is HTM, HTML, JSP, PLG, HTX, or STM by using browsers:
    • When you use the default custom domain name, Content-Disposition:'attachment=filename;' is automatically included in the response header. Web page objects will be downloaded as attachments, with no content displayed.
    • When you use the bound custom domain name, Content-Disposition:'attachment=filename;' is not included in the response header. You can preview the object content when your browser supports previews of web page objects.

For more information, see Static website hosting.

Procedure

  1. Log on to the OSS console.
  2. Click Buckets, and then click the name of the target bucket.
  3. ChooseBasic Settings > Static Pages. Click Configure in the Static Pages section. Configure the parameters listed in the following table.
    Parameter Description
    Default Homepage Specify an index page that functions similar to index.html. Only HTML objects can be specified as the index page. Static website hosting is disabled if you do not specify this parameter.
    Default 404 Page Specify the default 404 page to display when the requested resource does not exist. Only the HTML, JPG, PNG, BMP, or WebP object in the root folder can be specified as the default 404 page. Default 404 Page is disabled if you do not specify this parameter.
    Note You must ensure that both the index and error documents are readable. Otherwise, the static web page cannot be accessed.
  4. Click Save.