'Using AWS Amplify, can I do 301 redirect from /**/index.html to /**/?

Does AWS Amplify support dynamic matching syntax?

It works:

[
    {
        "source": "/<*>/index.html",
        "target": "/<*>/",
        "status": "301",
        "condition": null
    }
]

It can redirect /example/index.html to /example/, but /example/foobar/index.html is not redirected to /example/foobar/.

It seems that wildcard can't include any shashes.

It doesn't work:

[
    {
        "source": "/^(.*)\\/index\\.html$/",
        "target": "/$1/",
        "status": "301",
        "condition": null
    }
]

() cannot be reused by $1.

My workaround:

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source