简体   繁体   English

云端指向 s3 中的特定 object

[英]cloudfront pointing to a specific object in s3

I have CloudFront distributing a static website.我让 CloudFront 分发一个 static 网站。 the way it is now example.com leads to index.html.现在的方式是 example.com 导致 index.html。 to go to any other page I need to use the.html extension (example.com/contact.html).到 go 到我需要使用 .html 扩展名 (example.com/contact.html) 的任何其他页面。 is there a way to have example.com/contact lead to contact.html which would allow me to get rid of the.html extension in the URL有没有办法让 example.com/contact 导致 contact.html 这将使我摆脱 URL 中的 .html 扩展名

I tried to see if I can do it in both origins and behavior but haven't found a way.我试图看看我是否可以在起源和行为上做到这一点,但还没有找到办法。

If you enabled "Static Website Hosting" on your S3 bucket, uri that encounter folders with a index.html files, the index.html file will be served.如果您在 S3 存储桶上启用“静态网站托管”,uri 遇到包含 index.html 文件的文件夹,将提供 index.html 文件。 For example, instead example.com/contact.html -> example.com/contact/index.html should do the trick.例如,改为 example.com/contact.html -> example.com/contact/index.html 应该可以解决问题。

  1. Make sure you enable "Static Website Hosting" for you S3 bucket.确保为 S3 存储桶启用“静态网站托管”。 When enabling it you should get a access url - save it for (2).启用它时,您应该获得访问权限 url - 将其保存为 (2)。 https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteHosting.html

  2. Make sure your CloudFront distribution origin points to the S3 static website url - you shuold copy/paste it from the S3 static website configuration and NOT selecting the bucket from the drop down list when creating or updating the origin.确保您的 CloudFront 分发来源指向 S3 static 网站 url - 您应该从 S3 static 网站配置复制/粘贴它,并且在创建或更新来源时不要从下拉列表中选择存储桶。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM