tencent cloud


Static Website Hosting

Last updated: 2022-05-02 22:41:18


    A static website is a website that contains static content (such as HTML) or client scripts. You can configure static websites for buckets with a custom domain name through the console. A dynamic website contains server scripts such as PHP, JSP, or ASP.NET, and needs to be processed on a server. You can host static websites on Tencent Cloud COS, but cannot write server scripts. For deployment of a dynamic website, we recommend you use a CVM for server code deployment.


    A user created a bucket named examplebucket-1250000000 and uploaded the following files: 


    Static website

    Before enabled: Access the bucket via the following default domain name. When a download prompt pops up, save the index.html file to the local.


    After enabled: Access the bucket via the following access node, and then you can view the content of index.html directly in the browser.


    Forced HTTPS

    Before enabled: When the request source is HTTP, the access node URL keeps the HTTP unencrypted transport protocol:


    After enabled: The access node always maintains the HTTPS encrypted transport protocol regardless of whether the request source is HTTP or HTTPS:


    Index document

    An index file, the homepage of the static website, is a page returned when the root directory or any subdirectory of a website is requested, and is usually named index.html.
    When you access a static website via a bucket access domain name, such as https://examplebucketbucket-1250000000.cos-website.ap-guangzhou.myqcloud.com, and no specific page is requested, the web server will return the homepage.

    When your user accesses any directory (including the root directory) in a bucket using a URL ending with /, the index document in that directory will be matched preferentially. / is not mandatory in the root URL, so the index document is returned in response to either of the following URLs.


    If folders are created in the bucket, the index document needs to be added at each folder level.

    Error document

    Assume that when you visit the following page before configuring the error document, a 404 status code is returned, and the default error information is displayed on the page.


    When you visit the following page after configuring the error document, a 404 status code is also returned, but the specific error information is displayed on the page.


    Redirection rules

    To configure redirection rules for a hosted static website, the path of the replacement file must be an object path in your bucket.

    Configure error code redirection

    If the webpage.html document is set to Private Read/Write, when a user tries to access it, a 403 error is returned.
    After the 403 error code is redirected to 403.html, the browser will return the content of 403.html.
    If you do not configure a 403.html document, the browser will return an error document or default error message.

    Configure prefix match

    1. When you rename a folder from docs/ to documents/, the user will get an error when accessing the docs/ folder. So, you can redirect the request with the prefix docs/ to documents/.
    2. When you delete the images/ folder (i.e., deleting all objects with the prefix images/), you can add a redirection rule to redirect requests for any object with the prefix images/ to test.html.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support