vendredi 22 mai 2015

How do I create a custom 404 error page for a missing Amazon S3 Object

I am currently using my AWS S3 to store attachments, so I created an s3 bucket for it. So when I uploaded an attachment and I can view the attachment via the link:

https://.s3.amazonaws.com/

And if I delete that attachment above and then go to the link above, I get the following message:



    
    NoSuchKey
    The specified key does not exist.
    test/test.jpg
    [some request id]
    
    [some host id]
    
    


So I tried to create an html display "Attachment has been deleted". So what I tried is make the bucket a static website and set the routing rules to redirect to an html page I place in the bucket if the HttpErrorCodeReturnedEquals is 404. But that only works if I tried it using this url:

http://[bucket].s3-website-us-[region].amazonaws.com/

If I try using the link below, it doesn't work:

https://.s3.amazonaws.com/

Is there any other way I can redirect to an error html page if the object doesn't exist using the link above (https://.s3.amazonaws.com/)?

Thanks,

Thomasenter code here




Aucun commentaire:

Enregistrer un commentaire