Docs
ufile
Console Guide
Static Website Hosting

Static Website Hosting

Concept

A static website means all the website resources are composed of static content, such as HTML, JavaScript, CSS, picture files, etc. You can configure a static website hosting strategy for the US3 storage bucket of the already bound custom domain through the console.

Instructions For Use

You must first create a custom domain to use this feature. If the source station is a us3 domain, then note that:

  • CDN configuration follows the source site domain: The source station does not need a custom domain, but it will not recognize as our cdn acceleration, and the source site domain will generally have services.
  • CDN configuration follows the acceleration domain: The source station needs a custom domain for CDN acceleration, so the service will be normal.

Adjusted according to the settings on the configuration interface, where mandatory items are:

  • Default homepage: This homepage is the US3 storage bucket homepage returned when you visit the US3 storage bucket through a custom domain. If you have also enabled a subdirectory homepage, this file should also exist in the subdirectory, and you can customize the content based on your path.
  • The default 404 page (but when the subproject homepage is opened, and the file 404 rule is NoSuchKey, the default 404 is not filled in) is the error page returned when the browser accesses a non-existent (404) file in the US3 storage bucket.

The US3 storage bucket must be a public space, i.e., the storage bucket must be public read private write. Besides, if you access through the US3 default domain, the static website will be downloaded in the form of a file. The browser can only render the display by accessing through the custom domain bound to the US3 storage bucket.

For detailed working mechanisms, refer to the examples.

Examples

After you turn on static website hosting for the Bucket, you need to upload the file of the same name as the default homepage (such as index.html) to the target Bucket. If the Bucket includes a directory structure prefix/, the directory level must also include the index.html file. In addition, you need to upload a file of the same name as the default 404 page (such as error.html) to the target Bucket. The structure of the Bucket file is as follows:

Bucket
├── index.html
├── error.html
├── us3.png
└── prefix/
└── index.html

If the Bucket is bound to a custom domain example.com, and the default homepage of the configured static website is index.html, the default 404 page is error.html. When you visit the static website through a custom domain, the access rules are based on whether the subdirectory homepage has been enabled:

  • When the subdirectory homepage is not turned on

    • When you visit https://example.com/ and https://example.com/prefix/, US3 will return https://example.com/index.html.
    • When you visit https://example.com/us3.png, the us3.png file is normally obtained.
    • When you visit https://example.com/helloworld, because helloworld does not exist, US3 will return https://example.com/error.html.
  • When the subdirectory homepage is turned on

    • When you visit https://example.com/, US3 will return https://example.com/index.html.
    • When you visit https://example.com/prefix/, US3 will return https://example.com/prefix/index.html.
    • When you visit https://example.com/us3.png, the us3.png file is normally obtained.
    • When you visit https://example.com/helloworld, because helloworld does not exist, US3 will return the corresponding information according to your set file 404 rule:
      • If the file 404 rule is set to Redirect (default value), US3 will continue to check whether helloworld/index.html exists.
        • If the file exists, it returns 302 and redirects the access request to https://example.com/helloworld/index.html.
        • If the file does not exist, it returns 404.
      • If the file 404 rule is set to NoSuchKey, it directly returns 404.
      • If the file 404 rule is set to Index, US3 will continue to check whether helloworld/index.html exists.
        • If the file exists, it returns 200 and directly returns the file content.
        • If the file does not exist, it returns 404.