I'm using Amazon Simple Storage Service (Amazon S3) static website redirection rules. Amazon S3 adds a slash at the end of the URL that breaks my website.
Short description
Note: The following resolution applies only to Amazon S3 static website endpoints. For more information, see Website endpoints.
The addition of a trailing slash to the redirected URL is an expected behavior with Amazon S3 static website hosting.
To avoid the addition of a trailing slash in the redirected URL, use the following workaround:
- Configure an index document to host the S3 static website.
- Set the website redirect location in the metadata of the object to configure the redirect.
Resolution
Configure an index document to host the static website
First, complete the following steps to specify the name of the index document, and delete the redirection rules:
- Open the Amazon S3 console.
- From the Buckets list, choose the name of your bucket.
- Choose Properties.
- Under Static website hosting, choose Edit.
- On the Edit Static website hosting page, for Static website hosting, choose Enable.
- For Hosting type, select Host a static website.
- For Index document, specify the name of an object that you want to use to set the redirection metadata. An example name is, index.html.
Note: Don't begin your index name with a "/". For example, don't use: /index.html. Also, Amazon S3 object names are case sensitive.
- Delete the redirection rules.
- Choose Save changes.
Then, use the S3 console to configure the index document.
Set up the website redirection
Complete the following steps:
- Open the Amazon S3 console.
- From the Buckets list, choose the name of your bucket.
- Under Objects, choose your index document.
- Choose the Properties tab.
- In the Metadata section, choose Edit.
- Under Metadata, do the following:
Choose Add metadata.
For Type, select System defined.
For Key, choose x-amz-website-redirect-location from the dropdown list.
For Value, enter the redirect URL.
- Choose Save changes.
Related information
Configuring a webpage redirect