Automated the deployment of static sites to S3 with Ansible - not using any of Ansible's built in tools, necessarily, just using the CLI and local commands.
It's been working really well, but one issue I can't shake is when creating redirects, visiting the redirect with a trailing slash gives a 404, because S3 looks to serve /redirect/index.html rather than following the redirect.
Redirects are created through the API:
aws s3api put-object
...where 'html' is the folder configured to serve the website from, 'book' is the desired redirect, and the homepage is the desired destination.
Visiting https://devicelab.org/book behaves as expected. Visiting https://devicelab.org/book/ (note trailing slash) shows 404 page.
I've tried creating an additional object
html/book/ (with trailing slash) but still get the 404.
How can I configure this behaviour / work around the issue?