GAE PHP - 错误页面在本地显示,但在部署时不显示

时间:2015-07-09 16:38:10

标签: php google-app-engine

在本地投放时(通过应用引擎启动器)显示error.html页面,但在部署时,当我收到404 / etc响应时,它无法解析到错误页面。

我部署了新版本,但也没有帮助。我的YAML文件有什么问题,或者有人有任何其他建议吗?

由于

YAML文件

application: xxxmeowxxx
version: 1-5
runtime: php55
api_version: 1

handlers:
# Serve as static resources.
- url: /img
  static_dir: img
- url: /css
  static_dir: css
- url: /js
  static_dir: js
- url: /fonts
  static_dir: fonts
- url: /Documents
  static_dir: Documents


# Serve php scripts
- url: /(.+\.php)$
  script: \1

#serve php scripts without needing .php
- url: /(.+)
  script: \1.php

#serve index 
- url: /
  script: index.php

#Error handle
error_handlers:
  - file: error.html

2 个答案:

答案 0 :(得分:1)

支持的唯一错误类型是

  • over_quota,表示应用已超出资源配额;
  • dos_api_denial,提供给应用程序的DoS Protection配置阻止的任何客户端;
  • 超时,在您的应用收到回复之前已达到截止日期。

有关详细信息,请参阅https://cloud.google.com/appengine/docs/php/config/appconfig#PHP_app_yaml_Custom_error_responses

要获得404的错误页面,只需在index.php之后添加一个catch-all处理程序(/.*)即可打印出内容。

答案 1 :(得分:0)

我发现处理错误的最佳方法是创建路由器。你可以在你的yaml中包含一个catch(这将在你在yaml文件中声明的所有其他内容之后)并处理你的路由器文件中的所有请求。

YAML

#serve router
- url: /(.*)
script: /routes.php

路由器文件

$path       = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); //get full path