# Static websites and domains

> Configure the default home page and 404 page, host single-page apps, manage bound bucket domains and path prefixes, and use your own domain through a CDN.

S4 can host static websites: it returns the home page file when a directory is requested and returns your 404 page when a path doesn't exist. To serve your own domain publicly, connect a CDN.

To get there, go to **Object Storage (对象存储) › [Bucket list (桶列表)](https://console.bitiful.com/buckets)** › click the bucket name › **Website settings (网站设置)**.

> **Warning**
>
> **Creating new bucket domains is paused.** Since May 10, 2026, buckets can no longer bind new domains directly, and clicking **New bucket domain (新建桶域名)** shows "该功能已暂停" (this feature is paused). Use a [CDN domain](https://docs.bitiful.com/en/cdn/handbook/domains.md) instead. Domains that are already bound keep working and can still be managed.

## Deploy a static website

### Upload the website files

Upload your build output to the bucket, for example `index.html`, `404.html`, and `assets/`. See [Upload files](https://docs.bitiful.com/en/bitiful-s4/handbook/upload.md).

### Set the default files

In **Default file configuration (默认文件配置)**, click **Edit (编辑)**, enter `index.html` for **Home page file key (首页文件key)** and `404.html` for **404 file key (404文件key)**, and save.

### Connect a CDN

In [Static acceleration management (静态加速管理)](https://console.bitiful.com/cdn/list), add your domain, choose this bucket as the origin, and complete the CNAME record and HTTPS. See [Add and manage CDN domains](https://docs.bitiful.com/en/cdn/handbook/domains.md).

### Verify

Open `https://your-domain/`. It should return the content of `index.html`.

A CDN that uses an S4 bucket as its origin can read a private bucket, so the website doesn't need the bucket to be public. If your website lives in a subdirectory of the bucket, set an origin fetch path prefix in the CDN's [origin and origin fetch settings](https://docs.bitiful.com/en/cdn/handbook/origin.md).

## Default file configuration

This is the default for the whole bucket. It applies to access through CDN domains and bound bucket domains. It doesn't apply when you access through the bucket default domain (`bucket-name.s3.bitiful.net`).

Your account balance must be greater than 0 to edit it. Otherwise you see "当前账户余额不足，请充值后再配置默认文件" (the account balance is insufficient; top up before configuring default files).

- `Home page file key` (text): The file name returned when the domain root or a directory path is requested, for example `index.html`. Leave it empty to disable.

- `404 file key` (text): The file returned when the requested object doesn't exist, as a full path from the bucket root, for example `404.html`. When empty, S4 returns its built-in 404 page.

- `Return 404 status code` (switch, default: Off): On: The status code is 404 when the 404 file is returned. Off: Returns 200, as the file itself would. Single-page apps usually need this off. You can turn it on only after you enter a 404 file key.

Rules for file keys: can't begin with `/`; can't contain `..`, `?`, `#`, `\`, or invisible characters; up to 256 bytes.

Changes take effect immediately after you save. The CDN may still return old cached content, so you need to [purge the cache](https://docs.bitiful.com/en/cdn/handbook/cache.md).

### Access rules

Take the home page `index.html` and the 404 page `404.html` as an example:

| Request path     | What's in the bucket                                             | Result                    |
| :--------------- | ---------------------------------------------------------------- | ------------------------- |
| `/`              | Has `index.html`                                                 | Returns `index.html`      |
| `/docs/`         | Has `docs/index.html`                                            | Returns `docs/index.html` |
| `/docs`          | `docs` is a directory                                            | 302 redirect to `/docs/`  |
| `/docs/`         | The directory exists but has no `docs/index.html`                | Returns the 404 page      |
| `/a.png`         | Has `a.png`                                                      | Returns `a.png`           |
| `/none`          | Doesn't exist                                                    | Returns the 404 page      |
| `/private/a.png` | Accessed through a bucket domain, and the directory isn't public | 403, not the 404 page     |

The home page file is appended after every directory level, so enter only a file name, not a path such as `site/index.html`.

When no home page is set, requesting a directory doesn't list its files.

## Typical configurations

| Website type                                              | Home page file key | 404 file key | Return 404 status code |
| :-------------------------------------------------------- | :----------------: | :----------: | :--------------------: |
| Single-page app (React, Vue, etc., using history routing) |    `index.html`    | `index.html` |           Off          |
| Docs site or blog (multi-page)                            |    `index.html`    |  `404.html`  |           On           |
| Image host or download site                               |        Empty       |     Empty    |           Off          |

> **Info**
>
> After you point the 404 of a single-page app to `index.html`, missing images and scripts also get 200 and the home page content. When you publish a new version, upload the asset files first, then update `index.html`.

## Bound bucket domains

The **Bound domains (绑定域名)** table lists the domains bound earlier:

| Column                            | Description                                                                                                                                                                                                   |
| :-------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Domain (域名地址)**                 | Your domain                                                                                                                                                                                                   |
| **Path prefix (路径前缀)**            | The directory in the bucket that the domain root maps to. **Bucket root (桶根目录)** means none is set                                                                                                            |
| **CNAME domain (CNAME域名)**        | The address it must resolve to. A green icon means it has taken effect and red means it hasn't. When HTTPS is on but no certificate is selected, it also shows the DNS record that the auto certificate needs |
| **HTTPS configuration (HTTPS配置)** | Whether it's on, and the certificate validity period                                                                                                                                                          |

Right after you change DNS, the status may lag by a few minutes. Click **Refresh list (刷新列表)** to check.

### Manage a domain

Click **Manage domain (管理域名)** to configure HTTPS and the website.

<details open>
<summary>HTTPS configuration</summary>

Click **Edit**, turn on HTTPS, choose a certificate that's already deployed in the [Certificate Center](https://docs.bitiful.com/en/certs-center/intro.md) from the **Certificate (证书)** drop-down, and save. The certificate must match the domain.

When you turn on HTTPS, HTTP/2 and OCSP are on by default, and TLS 1.0 \~ 1.3 are supported.

</details>

<details open>
<summary>Website settings</summary>

Click **Edit** to set:

- **Path prefix**: The directory in the bucket that the domain root maps to. For example, with `site/v2/`, `https://www.example.com/index.html` reads `site/v2/index.html` in the bucket. Empty means the bucket root. The rules are the same as for [public read directories](https://docs.bitiful.com/en/bitiful-s4/handbook/public-read.md): up to 512 bytes, and `*` isn't supported.
- **Home page file key** and **404 file key**: Enter them relative to the path prefix. When empty, the bucket's default file configuration applies.
- **Return 404 status code**: Same meaning as above.

</details>

After you set a path prefix:

- The domain is read-only and handled only as a website. It can't upload, delete, or list objects.
- It can access only files within the prefix.
- Read permission is still determined by [public read](https://docs.bitiful.com/en/bitiful-s4/handbook/public-read.md). Saving the settings here doesn't change permissions, and the page tells you which directories aren't public.
- Presigned access: sign the full object key (including the prefix) with the bucket default domain, then replace the link's domain with this domain and remove the prefix at the start of the path. SigV2 signatures aren't supported.

### Delete a domain

Click **Delete (删除)** and confirm, and the domain stops serving immediately. Because creating new ones is paused, **you can't bind it again after deleting**, so switch the domain to a CDN before you delete it.

### Migrate to a CDN

### Add a CDN domain

In [Static acceleration management](https://console.bitiful.com/cdn/list), add the same domain, choose the original bucket as the origin, and deploy a certificate. If you had set a path prefix, enter the same origin fetch path prefix in the CDN's [origin and origin fetch settings](https://docs.bitiful.com/en/cdn/handbook/origin.md).

### Switch DNS

Change the domain's CNAME to the address the CDN provides.

### Confirm, then delete

After DNS has fully taken effect and access works, delete the old bucket domain.

> **Info**
>
> Website settings on a bucket domain aren't carried over to the CDN automatically. Access through a CDN uses the bucket's **Default file configuration**, so set it up first.

## FAQ

<details>
<summary>The root path returns 403 or a file list</summary>

No **Home page file key** is set, or you're using the bucket default domain. The bucket default domain doesn't support website features.

</details>

<details>
<summary>The site still shows old content after an update</summary>

CDNs and browsers cache content. [Purge the cache](https://docs.bitiful.com/en/cdn/handbook/cache.md) after you publish, and use hashed file names for static assets.

</details>

<details>
<summary>The page downloads instead of opening</summary>

1. Confirm you're using your own domain, not the bucket default domain.
2. Check that the file's Content-Type is `text/html`.

</details>

<details>
<summary>Does a domain in mainland China need ICP filing?</summary>

Yes. A domain that uses mainland China CDN nodes must complete ICP filing.

</details>
