【问题标题】:Unable to redirect Not Found Page to 404.php (gae php yaml)无法将未找到页面重定向到 404.php (gae php yaml)
【发布时间】:2015-06-04 06:45:47
【问题描述】:

我在运行WEBSITE/images/weq时出现以下错误,我认为应该被捕获并重定向到404.php,但它不起作用,请帮助!!

错误:未找到 在此服务器上找不到请求的 URL /images/weq。

application: smile-bee-999
version: 1
runtime: php55
api_version: 1

default_expiration: "3d"

handlers:

- url: /
  script: index.php

- url: /favicon.ico
  static_files: favicon.ico
  upload: favicon.ico

- url: /sitemap.xml
  static_files: sitemap.xml
  upload: sitemap.xml  

- url: /robots.txt
  static_files: robots.txt
  upload: robots.txt  

- url: /images
  static_dir: images

- url: /css
  mime_type: text/css
  static_dir: css

- url: /font
  mime_type: text/font
  static_dir: font

- url: /font-awesome/css
  mime_type: text/css
  static_dir: font-awesome/css  

- url: /js
  mime_type: text/javascript
  static_dir: js

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

- url: /about.php
  script: about.php

- url: /product.php
  script: product.php

- url: /contact.php
  script: contact.php

- url: /.*
  script: 404.php

【问题讨论】:

  • 您的 [项目根目录]/images 文件夹中是否真的有一个名为“weq”的文件?
  • 文件夹中没有 weq 文件,因此,我希望它会被重定向到 404 ...
  • 啊,我明白了。不幸的是,我认为您不能像 Anhuin@ 指出的那样为静态文件指定自定义 404 文件。请注意,您看到的错误页面确实返回 HTTP 404。

标签: php google-app-engine http-status-code-404 yaml


【解决方案1】:

您的问题不是很清楚,我猜您的 404 错误处理程序正在为您的处理程序工作,除了带有 static_dir 的处理程序?

如果是: 我认为您不能使用 static_dir 来完成这项工作,因为作为静态文件提供的文件没有任何处理程序配置。因此,您不能指定自己的 404 处理程序。

如果否: 看一眼 https://cloud.google.com/appengine/docs/php/config/appconfig#PHP_app_yaml_Custom_error_responses

【讨论】:

  • 非常感谢...当我创建文件夹 (static_dir) 并将所有文件夹 (css/js/images) 移动到此 static_dir 时,它可以工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-01-06
  • 1970-01-01
  • 2012-12-14
  • 1970-01-01
  • 2021-08-17
  • 2015-08-07
  • 1970-01-01
相关资源
最近更新 更多