Amazon web services 带通配符条件的AWS S3路由规则

Amazon web services 带通配符条件的AWS S3路由规则,amazon-web-services,amazon-s3,Amazon Web Services,Amazon S3,我在S3中存储了一组具有相同文件夹结构但内容不同的用户文件夹 /user/userA/application/folder/structure/file.xml /user/userB/application/folder/structure/file.xml 如果s3文件夹结构还不存在,我想将用户重定向到备用文件夹(包含备用内容) /user-fallback/application/folder/structure/file.xml 我试图在重定向规则中添加一个通配符参数,但S3将*作为

我在S3中存储了一组具有相同文件夹结构但内容不同的用户文件夹

/user/userA/application/folder/structure/file.xml
/user/userB/application/folder/structure/file.xml
如果s3文件夹结构还不存在,我想将用户重定向到备用文件夹(包含备用内容)

/user-fallback/application/folder/structure/file.xml
我试图在重定向规则中添加一个通配符参数,但S3将
*
作为文本读取

<RoutingRules>
    <RoutingRule>
        <Condition>
            <KeyPrefixEquals>user/*/</KeyPrefixEquals>
            <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
        </Condition>
        <Redirect>
            <ReplaceKeyPrefixWith>user-fallback/</ReplaceKeyPrefixWith>
        </Redirect>
    </RoutingRule>
</RoutingRules>

使用者/*/
404
用户回退/
因此,只有以
/user/*/
开头的URL才能正确重定向到
用户回退文件夹结构

我有20多个用户,所以创建单独的路由规则也不起作用(S3有路由规则限制)


有什么想法吗?

路由规则不允许使用通配符——但您不能为任何404错误设置自定义重定向吗?参见此处的示例#2: 只需将条件更改为:

404

这样行吗

这应该有效:

<RoutingRules>
    <RoutingRule>
        <Condition>
            <KeyPrefixEquals>user</KeyPrefixEquals>
            <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
        </Condition>
        <Redirect>
            <ReplaceKeyPrefixWith>user-fallback/</ReplaceKeyPrefixWith>
        </Redirect>
    </RoutingRule>
</RoutingRules>

用户
404
用户回退/

您在这方面有过进步吗?还想知道Amazon S3路由规则是否允许任何类型的通配符?