我正尝试在 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/