Why is AWS S3 returning a 404 when I can see the f

2019-07-08 19:24发布

问题:

I the title pretty much sums up my problem. I have uploaded the files using the web interface, can launch the index.html, but the PDF in an assets folder returns a 404.

The server responds with:

404 Not Found

Code: NoSuchKey
Message: The specified key does not exist.
Key: assets/PDF/piano0817.pdf
RequestId: 02770C292FC4DBFA
HostId: zSn07EPw7JngHLCdcveteFDJNKATslKDCSKkJSAhsFsbW+gfeVQwvFMu3WMcY513iwt32F/OG1c=```

I have waited the prescribed hour but S3 will still not serve my PDF. What am I doing wrong?

回答1:

Go to S3 bucket properties -> Static web hosting and add index.html as Error document.

It considers everything as directory once you append something to host URL. Now after adding index.html as Error document, when it doesn't find the required path as a folder, it will go to index.html and redirect your request.