google-app-engine - 静态网站的appengine自定义404页面

标签 google-app-engine error-handling http-status-code-404

我正尝试在 Google AppEngine 上托管一个简单的静态网站,但我在设置自定义 404 页面时遇到了问题。

我的 app.yaml 为所有请求提供静态文件(来自 www 子目录):

application: id
version: v
runtime: python27
api_version: 1
default_expiration: "1d"
threadsafe: yes

handlers:
- url: (.*)/
  static_files: www\1/index.html
  upload: www/index.html
- url: /
  static_dir: www

error_handlers:
- file: 404.html

但是在尝试访问不存在的文件时,我没有看到 404.html,而是默认的 GAE 错误消息。

日志显示:

Static file referenced by handler not found: www/does-not-exists/index.html

Static file referenced by handler not found: www/does-not-exists.html

我做错了什么?

最佳答案

这行不通。您的静态处理程序将匹配大多数内容,并且您不能为 404 执行 error_handler。

关于google-app-engine - 静态网站的appengine自定义404页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17857607/

相关文章:

google-app-engine - 运行计划备份时以编程方式禁用数据存储写入?

java - 谷歌应用引擎: DeadlineExceededException in dev

python - Python按顺序运行函数;如果失败,请停止

html - Servlet返回“HTTP状态404请求的资源(/Servlet)不可用”

python - 在 Python 中检测软 404 重定向

java - GAE java - Blobstore 找不到文件

python - 安卓工作室 : IncorrectOperationException when 'Add as Library' is clicked whilst trying to configure Google Apps Endpoints client libraries

c++ - 无法在以下代码中输入n(cin >> n)

cmd - 编程时如何缩短控制台上显示的错误代码

Symfony 2 : 404 Not Found Error when tryes to open/app_dev. PHP