hosting multiple sites on S3 bucket serving index.html from directory path

怎甘沉沦 提交于 2020-05-25 07:55:32

问题


I'm new to using AWS S3. I want to know if it's possible to host multiple static websites in one bucket using the website route directing meta data option. I am planning to have multiple folders each with their own index.html, but how can I configure the bucket settings to route to each individual site when a user types the address.

For example by typing

http://<bucket-name>.s3-website-<AWS-region>.amazonaws.com/folder1 

will take them to website 1

and

http://<bucket-name>.s3-website-<AWS-region>.amazonaws.com/folder2 

will take them to website 2

If this is possible, is there any way to also achieve the configuration using the AWS CLI?


回答1:


This is possible with a slight modification to the URL. You need to use the URLs as follows with the trailing slash to serve the index.html document inside folder1 and folder2.

http://<bucket-name>.s3-website-<AWS-region>.amazonaws.com/folder1/
http://<bucket-name>.s3-website-<AWS-region>.amazonaws.com/folder2/

If you create such a folder structure in your bucket, you must have an index document at each level. When a user specifies a URL that resembles a folder lookup, the presence or absence of a trailing slash determines the behavior of the website. For example, the following URL, with a trailing slash, returns the photos/index.html index document.

Reference: Index Document Support



来源:https://stackoverflow.com/questions/45928994/hosting-multiple-sites-on-s3-bucket-serving-index-html-from-directory-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!