You can use the PutBucketWebsite API of OSS to set your bucket to the static website hosting mode and access the static website from the bucket endpoint.
If your selected bucket is located in China (Hangzhou), after the configuration takes effect, the domain of the static website is as follows:
Content-Disposition:'attachment=filename;'is automatically added to the response header. That is, when you use a browser to access a Webpage object, the object is downloaded as an attachment. If you use a custom domain to access OSS, the information is not added to the response header. For more information about how to use a custom domain to access OSS, see Bind a custom domain.
OSS provides the following features to help you manage static websites hosted in OSS more easily:
Index document support
The index document is the default index page (such as index.html) that OSS returns when a user directly accesses the root domain of a static website. If you set a bucket to the static website hosting mode, you must specify the index document.
Error document support
The error document is an error page that OSS returns if an HTTP 4XX error (such as 404 NOT FOUND) occurs when a user accesses a static website. By specifying the error document, you can provide your users with appropriate error messages.
For example, you set the index document to index.html, the error document to error.html, the bucket name to oss-sample, and the endpoint to 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
- To access a bucket-based static website by using a custom domain, you can bind a custom domain.
- When you set a bucket to the static website hosting mode:
Note If you use an Archive bucket, you must specify Standard objects or restored Archive objects as the index document and error document. Otherwise, the static website cannot be accessed.
- The index document is required and 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 of the static website, and returns the result of the GetBucket operation for authorized access to the root domain of the static website.
- OSS returns a specified object to users who access the root domain of a static website or an object that does not exist in OSS. OSS also charges a fee for such requests and the generated traffic.