You can enable the static website hosting feature for buckets via the console. After enabling, COS will automatically generate a static website domain (format: <Bucket-Appid>.cos-website.<Region>.myqcloud.com, which will be displayed in the console automatically). Accessing the bucket via this domain enables website effects such as homepage display and error code redirection. If using the bucket's default domain (format: <Bucket-Appid>.cos.<Region>.myqcloud.com), no website behavior will occur, maintaining direct file access within the bucket.
Static websites refer to sites containing static content (such as HTML) or client-side scripts, whereas dynamic websites include server-side scripts like PHP, JSP, or ASP.NET, which require server-side processing. Buckets only support hosting static websites and do not support server-side scripting. When you need to deploy dynamic websites, it is recommended to use Lighthouse for server-side code deployment.
Note:
If users access files using the default domain (including the static website domain), direct preview is not supported. For details, see Setting Up a Static Website. Operation Steps
2. On the bucket card page, go to the specified bucket page and switch to the Property Settings tab.
3. Go to Bucket Access Permissions and set the bucket access permission to public read, private write.
Note:
Public read carries a risk of unauthorized access; please proceed with caution.
4. Go to Static Website Hosting, click Edit and enable Current Status, then proceed to Page Management.
5. Complete the static website settings one by one.
Note:
Static website access nodes are case-sensitive. Please ensure that the file names and extensions entered when index documents, error pages, and redirection rule prefix matching are configured match the case of the files in the bucket exactly.
Page Management, with configurations as follows.
Access domain (auto-generated):
After static website hosting is enabled, an access domain will be automatically generated in the format: <Bucket-Appid>.cos-website.<Region>.myqcloud.com. Accessing via this domain will activate functionality effects such as redirection and index documents configured for the static website. Index document (required): The index document is the homepage of the static website. It is the page returned when a user requests the root directory or any subdirectory of the website. This page is usually named index.html.
Note:
If a folder is created in the bucket, the index file needs to be added at each level of the folder.
The pages in the static website, including index documents, error documents, and so on (such as index.html and error.html), are created and written by you, then uploaded to the COS bucket.
Error document (optional): The error document refers to the page returned when an error occurs while accessing the static website. This configuration allows you to customize the error document. When the static website fails to respond to a user request, the specified custom error page will be returned. For example, if you configure an error document named error.html, the error.html page will be returned to provide guidance when users encounter HTTP errors during access. If no error document is configured, the default error message will be displayed when users encounter HTTP errors.
Error document response code: This item is displayed if an error document is set. You can configure the HTTP response code when the error document is returned to be the original error code or 200.
Redirection rules (optional): By configuring redirection rules, you can conditionally redirect requests based on specific file paths, prefixes in requests, or response codes. For example, if you delete or rename a file in the bucket, you can add a redirection rule to redirect requests for that file to another file.
Error code: Currently, only 4xx error codes (such as 404) can be redirected in the redirection rules. You can optionally customize the error page. If a user triggers a corresponding HTTP error, you can provide additional guidance on this error page.
Prefix matching: You can use the prefix matching rules to redirect files or folders in the bucket. For specific examples, see Redirection Rules. CAM, the relevant configurations are as follows.
Force HTTPS (optional): When you enable Force HTTPS, the static website's access node will force all user accesses to open via HTTPS protocol.
Ignore HTML extension (optional): If the access path is index, the index.html object will be automatically matched and returned.
6. Click Save to complete the static website configuration.