S3静态网站索引文件 [英] S3 static website index document

查看:111
本文介绍了S3静态网站索引文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将静态网站上传到s3存储桶。我已经做到了。我已经创建了my_bucket,然后创建了一个名为test_folder的sub_bucket,并在其中上传了我的所有CSS,HTML,JS文件。

I'm trying to upload my static website to my s3 bucket. I've managed to accomplish this. I've created my_bucket and then create a sub_bucket named test_folder and in that I uploaded all my css, html, js files.

现在看起来像这样:

It would look like this now:

 my_bucket/
  test_folder
    index.html

我能够查看我的index.html,太棒了! :D但是我的问题是建立索引文档,因为index.html位于一个sub_bucket:test_folder / index.html当我尝试保存它时,给了我

And I was able to view my index.html, horray! :D. But my question is in setting up the index document, since the index.html is located to a sub_bucket: test_folder/index.html when I try to save it, gave me The

IndexDocument后缀格式不正确

IndexDocument Suffix is not well formed

是否可以在sub_bucket中链接index.html?如果是,怎么办?如果没有,是否有其他方法可以实现?我这里有一个屏幕截图链接

Is it possible to link the index.html in a sub_bucket? If yes, how? If not, is there an alternative way to achieve this? I have here a screenshot link

推荐答案

尽管索引文件经常用于不同的目的,但从概念上讲,它最初旨在成为每个文件中所有文件的索引(目录列表或其他内容摘要)文件夹,因此此配置参数指定索引文件以返回整个存储桶中每个文件夹的(如果该文件存在于文件夹中)...这不是单个配置物

Though often used for different purposes, the index document was originally intended, conceptually, to be the "index" (directory listing or other content summary) of all of the files within each folder, so this configuration parameter specifies the index document to return for each folder in the entire bucket, if such a document exists within the folder... this isn't a single configuration "thing" for the bucket as a whole.

如果您的尝试配置已被S3接受,则假定存储桶名称为 example.com,则会产生以下影响:

If your attempted configuration had been accepted by S3, it would have had the following impact, assuming a bucket name of "example.com":

browser address bar          file (object) actually returned
---------------------------  ------------------------------------
http://example.com           example.com/test/index.html
http://example.com/help      example.com/help/test/index.html
http://example.com/foo/test  example.com/foo/test/test/index.html

这似乎不太可能是您真正想要的。

It seems very unlikely that this is what you actually intended.

但是,这就是索引文档的工作方式……它们在概念上旨在与目录层次结构每个级别上的其他事物相关联,它们当然可以是文件的实际列表,或者可以是目录中的索引任何页面的含义都更加广泛,模糊和笼统,例如您希望访问者在访问您网站上的特定目录时看到的着陆页,这当然在现代网络中通常并不常见

However, but that is how index documents work... they are conceptually intended to be related to the other things at each level of the directory hierarchy, which of course could be the actual listing of files, or could be an "index" in a much more broad and vague and general sense of any "page," such as a landing page you want a visitor to see when they go to a specific "directory" on your site, which of course, in the modern web is not typically conceptualized as a "directory" but rather simply as a "page."

因此,索引文档必须直接位于同一 / 分隔符,并且不能在其自己的规范内包含其他 /

So the index document has to be immediately under the same / delimiter and can't contain an additional / within its own specification.

索引文档例如example.com必须在example.com/index.html中为红色(假设 index.html是您选择的索引文件名)-必须将其存储在它建立索引的目录中,就像在传统的Web服务器上一样,其中配置时,Web服务器将实际显示文件的目录列表,如果索引页面实际存在,则用索引页面替换该目录列表。当然,S3没有默认的目录列表页面功能。

The index document for example.com has to be stored in example.com/index.html (assuming "index.html" is your chosen index filename) -- it has to be stored within the "directory" that it indexes, just like on a conventional web server, where, in some configurations, the web server will actually display a directory listing of files, with the "index" page replacing that directory listing in cases where the "index" page actually exists. Of course, S3 doesn't have default directory listing page functionality.

http: //docs.aws.amazon.com/AmazonS3/latest/dev/IndexDocumentSupport.html

与索引文档相反,如果错误文档您配置它是一种全局配置,无论桶中404出现在哪里,都将使用它,因此该条目中支持斜杠。 AWS控制台提示仅针对这两个条目的性质提供了提示,它们的行为是如此不同,以至于可以说它们在视觉上应该更分开。

In contrast to the index document, the error document, if you configure it, is a global configuration that is used regardless of where, within the bucket, the 404 occurs, so slashes are supported in that entry. The AWS console prompts are light on hints as to the nature of the two entries, which are so different in their behavior that they arguably should be more separated, visually.

您会注意到, sub-bucket并不是您所描述的实际术语,它是一个在其键(路径)中带有定界符的对象,从而给出了外观

You'll note that "sub-bucket" isn't an actual term, for what you are describing, which is an object with delimiters in its key (path), which gives the appearance of being nested under a directory or folder.

为清楚起见,我在整个答案中都非常随意地使用了文件夹和目录一词,具有常规含义...但是为了技术准确性,我将提到S3对象并不是真正以在目录中的分层方式内部存储的。它以这种方式出现,并且出于实际目的,它以这种方式工作。但是,实际上是 / 字符的情况,虽然几乎是对象键中的另一个字符,但由于它的常规用法而被当作分隔符进行了特殊处理与目录常规文件系统不同,目录中的每个文件的数量与S3无关,不会对性能造成任何影响,并且在大型文件系统中不需要以与常规文件系统相同的方式进行管理。由于 S3在内部为每个对象的键(路径)散列其内部存储分区逻辑。

For clarity, I have used the words "folder" and "directory" very casually all throughout this answer, with the conventional meaning... but for technical accuracy, I'll mention that S3 objects are not really stored internally in a hierarchical fashion "in directories." It appears this way, and for practical purposes, it works that way; however, it's actually the case that the / character, while close to being just another character in the object key, although it gets some special treatment as a delimiter because of its conventional use as a directory delimiter.Unlike some more conventional filesystems, the number of "files in each directory" does not pose any performance concern with S3 and doesn't need to be managed in the same way as is needed in a conventional filesystem when a large number of files exists, since S3 internally hashes the key ("path") of each object for its internal storage partitioning logic.

这篇关于S3静态网站索引文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆