【问题标题】:Can't direct a domain to a static page using AWS S3无法使用 AWS S3 将域定向到静态页面
【发布时间】:2020-06-02 19:48:18
【问题描述】:

我按照本教程 How to Point your Domain to an S3 Website Bucket 操作,效果很好。

我的域名,例如domain.com 指向我的 S3 存储桶 bucket.com.s3-website.eu-central-1.amazonaws.com。

但是,默认情况下 index.html 不显示,例如如果我使用 URL domain.com 我得到这个:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>AE243F85AC91D283</RequestId>
<HostId>zAcaxygehDiR1EC6/JJADndO+JlvA7dYSAu+uOL7qWtdDGWLLQ+vGCoqescLUAKLH51/kLD/StM=</HostId>
</Error>

但是,如果我使用 domain.com/index.html 或 bucket.com.s3-website.eu-central-1.amazonaws.com,则会出现 index.html 页面。

只有当我使用 domain.com 而不是上面的时它才不会显示。

存储桶拥有所有公共权限。

【问题讨论】:

  • 您是否将 index.html 指定为存储桶上的索引文档,如 here 所示?
  • 是的,我确实指定了它。
  • 你看到我的回答了吗?有帮助吗?

标签: amazon-web-services amazon-s3


【解决方案1】:

您遇到了错误。如果您只想在使用普通 domain.com url 时显示 index.html 页面,那么您还需要将 index.html 指定为错误页面。

或者,您可以使用下面框中的重定向规则来执行此操作

<RoutingRules>
    <RoutingRule>
    <Condition>
      <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals >
    </Condition>
    <Redirect>
      <ReplaceKeyWith>index.html</ReplaceKeyWith>
    </Redirect>
    </RoutingRule>
</RoutingRules>

【讨论】:

    猜你喜欢
    • 2021-01-08
    • 1970-01-01
    • 1970-01-01
    • 2018-05-26
    • 2018-01-21
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 2011-11-24
    相关资源
    最近更新 更多