Configure static website hosting
Static website hosting serves bucket objects as pages or files and can redirect visitor requests. Configuring hosting does not upload files or change object access permissions.
Requirements and consequences
Static website hosting applies to a single general purpose bucket whose policy allows reading. Open File > Accounts…, select the account, click Edit…, then open Capabilities. Under Static website hosting, configure the policy and assignments for the bucket. Enable only features the service supports: reading, writing, deletion, global redirects and routing rules.
Under Features, GetBucketWebsite enables viewing, PutBucketWebsite creation or replacement, DeleteBucketWebsite deletion, RedirectAllRequestsTo global redirects and RoutingRules routing rules. See account capabilities. Reading must succeed before any change or deletion. Without writing support, fields can be viewed; Disabled remains available to delete an existing configuration when deletion is supported.
On Amazon S3, the corresponding permissions are s3:GetBucketWebsite, s3:PutBucketWebsite and s3:DeleteBucketWebsite. They do not allow visitors to read objects. Public access must be authorized separately, taking account and bucket public access settings into account.
Changing modes replaces the entire website configuration. Disabled removes it; objects and their permissions are retained.
Choose a mode
- In the S3 pane, select the bucket.
- Open Properties > Static website hosting.
- Wait for Remote configuration to load.
- Choose Mode:.
- Disabled removes the configuration.
- Host a website serves documents.
- Redirect all requests redirects every request.
- Fill in the fields for the selected mode, then save as described below.
Modes and fields may be disabled when the account policy does not allow writing them.
With no remote configuration, Disabled is selected, document and host fields are empty, no rules are defined and Destination protocol is Keep request protocol. S3Client does not automatically fill in index.html. Changes remain local until you click OK in the properties.
Serve documents
Under Website hosting, Index document is required: enter a name such as index.html, without a slash. Select Error document to supply a nonempty object key, optionally including a prefix, such as errors/404.html. Clear the checkbox to omit an error document.
The objects must already exist or be uploaded separately. Names and keys are case-sensitive.
Redirect every request
Enter a hostname such as www.example.com in Destination host, without a scheme, path, port or credentials. Destination protocol offers Keep request protocol, http and https. The first preserves the request protocol. This mode replaces hosting documents and rules.
Configure routing rules
In Host a website, use Routing rules. A maximum of 50 rules is accepted.
- Click Add to open Website routing rule.
- If needed, enable Key prefix condition or HTTP error condition, then enter the prefix or a three-digit HTTP code from
100to599. When both are set, both must match; without a condition, the rule has no such filter. - Configure at least one redirect setting: Destination host, Destination protocol, HTTP redirect code, Replace key prefix with or Replace entire key with.
- Use a hostname alone if specifying a host. Enter a three-digit code from
100to599if specifying a redirect code. - Choose only one replacement: a prefix or the entire key. An empty replacement string can remove a prefix.
- Click OK.
- Select a rule to use Edit, Remove, Move up or Move down.
Select the checkbox for each optional field you want to apply. A new rule starts with no condition or redirect setting and with Keep request protocol selected. That choice preserves the protocol but does not count as a redirect setting on its own: supply another field or choose http or https. Invalid input displays a diagnostic and prevents accepting the dialog with OK.
The list order is preserved when writing and determines priority among matching rules. The generated XML document must stay within 128 KiB and contain valid XML characters.
Save and verify
- Check the mode, document names, destinations and rule order.
- Click OK in the properties.
- Confirm complete deletion or replacement when requested.
- Wait for the operation to finish, then reopen the tab to reread the configuration.
- Use the website address supplied by the service to check a document and expected redirects. S3Client does not create a domain name or DNS configuration.
Use the website address supplied by the service, which differs from the S3 API endpoint and the object access links described under addresses and links. On Amazon S3, website endpoints support HTTP, not HTTPS; selecting https as the destination protocol configures a redirect, not HTTPS on the bucket. Requester Pays buckets cannot be accessed through this endpoint. See AWS website endpoints.
Also check document Content-Type, such as text/html. An object-specific redirect, x-amz-website-redirect-location, is configured separately under object metadata.
A denied website request may be caused by object permissions even when the configuration was saved.
View XML… displays the remote configuration as XML without allowing you to edit it. Unsupported configuration means S3Client cannot edit it. With Replace configuration, you prepare a new configuration that will completely replace the old one when saved, including elements that are not displayed. Keep remote configuration discards only your website hosting changes and restores the loaded configuration; changes prepared in other tabs are retained.
Before writing, S3Client checks for concurrent changes. Reload remote configuration loads remote settings and discards local changes; Replace remote configuration applies your values after confirmation; Cancel stops saving. If account settings changed or reading failed, fix the cause and reopen the properties.
Another client can still change the configuration between this check and saving. When you change several tabs, an operation that has already succeeded is not rolled back if a later operation fails: reread the settings actually saved before trying again.