AWS Amplify Console显示奇怪的xml而不是404 [英] AWS Amplify Console shows weird xml instead of 404

查看:110
本文介绍了AWS Amplify Console显示奇怪的xml而不是404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过AWS Amplify控制台部署了一个香草js应用程序,并从amplifyapp.com获得了一个子域.当我直接调用源文件时 master.myappid.amplifyapp.com/js/index.js ,其内容应按应有的方式显示.另外,在不带任何特定文件的情况下调用域时,将按预期显示 index.html .但是,当调用不存在的文件夹或仅是子文件夹而不是其中的特定文件时,它不会抛出404,而是显示一个奇怪的xml响应,如下所示:

I´ve deployed a vanilla js app via the AWS amplify console and got a subdomain from amplifyapp.com. When I call source files directly, f.e. master.myappid.amplifyapp.com/js/index.js, the content is being shown like it should. Also, when calling the domain without any specific file, it will show the index.html as expected. But, when calling non-existant folders or just a sub-folder, not a specific file in it, it will not throw a 404, but instead show a weird xml response, something like this:

<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>X</RequestId><HostId>X</HostId></Error>

此外,在调用不存在的文件时,/abc.html ,它也会显示此消息.当调用没有index.html,不存在目录或不存在文件的子目录时,如何设置规则以使AWS Amplify Console显示404?

Also, when calling non-existant files, f.e. /abc.html, it will also show this message. How can I setup a rule to make AWS Amplify Console show a 404 when sub-directories with no index.html, non-existant directorys or non-existant files are being called?

推荐答案

因此,该解决方案比预期的要容易得多.只需添加一个重写规则(在左侧边栏的放大控制台中),其源地址为< *> ,目标地址为/404.html (或其他错误页面)和类型"404(未找到)".现在,所有404都将重定向到404.html,您必须为404.html创建并编写一些内容丰富的404页面.

So, the solution was way easier than expected. Just add a rewrite rule (In your amplify console at the left sidebar) with a source address of <*>, a target address of /404.html (or any other error page) and a type of "404 (Not found)". Any 404´s will now be redirected to 404.html, which you will have to create and write some informative 404 page for ;)

这篇关于AWS Amplify Console显示奇怪的xml而不是404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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