You can call PutBucketWebsite to configure static website hosting for your bucket and access the static website through the OSS domain name of the bucket.
- Starting from August 13, 2018,
Content-Disposition:'attachment=filename;'will be added to the response header when you access webpage objects stored in a Mainland China region or China (Hong Kong) through an OSS domain name. Webpage objects will be downloaded as attachments. Webpage objects of the following MIME types (TEXT or HTML) will be affected: HTM, HTML, JSP, PLG, HTX, and STM. This adjustment will not affect webpage objects accessed through custom domain names. We recommend that you bind a custom domain name to your bucket and use this custom domain name to access hosted websites. For more information, see Bind a custom domain.
- For more information about the API operation of configuring static website hosting, see PutBucketWebsite.
After the configuration takes effect, the OSS domain name to access a static website hosted in a bucket located in China (Hangzhou) is as follows:
OSS provides the following features to manage static websites hosted in OSS:
- Index document support
An index document links to a default index page returned by OSS when a user directly accesses the root domain name of a static website. The index page functions similar to index.html. To configure static website hosting for your bucket, you must specify an index document.
- Error document support
An error document links to an error page returned by OSS if HTTP 4xx-related error messages such as 404 NOT FOUND occur when a user accesses a static website. By specifying an error document, you can provide your users with appropriate error messages.
For example, set the index document to index.html and the error document to error.html. Specify oss-sample as the bucket name. The endpoint is oss-cn-hangzhou.aliyuncs.com.
- When a user accesses
http://oss-sample.oss-cn-hangzhou.aliyuncs.com/directory/, the user actually accesses
- If the object does not exist when a user accesses
http://oss-sample.oss-cn-hangzhou.aliyuncs.com/object, OSS returns
|Configure static website hosting||A user-friendly and intuitive Web application|
|Java SDK||SDK demos in various languages|
- To access a static website hosted in a bucket through a custom domain name, you can Bind a custom domain.
- When you set a bucket to the static website hosting mode:
Note If you use an archive bucket, make sure that the objects to be specified for the index and error documents are standard objects or restored archives. Otherwise, the static website will not be accessible.
- The index document is required, whereas the error document is optional.
- The specified index document and error document must be objects in the bucket.
- After you set a bucket to the static website hosting mode:
- OSS returns the index document for anonymous access to the root domain name of the static website. OSS returns the result of GetBucket for authorized access to the root domain of the static website.
- OSS returns a specified object to users who access the root domain name of a static website or an object that does not exist in OSS. OSS also charges fees for such requests and generated traffic.