Remove trailing slashes from AWS S3 stating webhosting site


I have generated my WordPress website as static html and deployed it to s3 bucket to serve as static website.

Here is my website endpoint:

My SEO team wants that the page URLs must not contain trailing slashes, but I could not find any document online that could allow me to get rid of trailing slashes from the URL eg : leads to

I tried using redirects but then it ends up in too many redirects.

        "Condition": {
            "KeyPrefixEquals": "demo/"
        "Redirect": {
            "ReplaceKeyPrefixWith": "demo"

Please advice !

asked 2 years ago1722 views
1 Answer

May you try this LambdaEdge function: LambdaEdgeRemoveTrailingSlash ?

It seems to solve your issue.

You may read more about LambdaEdge here too:

answered 2 years ago
profile pictureAWS
reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions