首页 > 解决方案 > 应用引擎下载 PHP 代码而不是显示

问题描述

我正在使用 PHP55 通过 Google App Engine 在标准环境中运行网页。当我单击表单上的提交按钮时,它会下载应该执行的相应 PHP 代码。这是我的app.yaml

runtime: php55
api_version: 1
threadsafe: true

handlers:
- url: /
  static_files: www/index.html
  upload: www/index.html

- url: /signUp.html
  static_files: www/signUp.html
  upload: www/signUp.html

- url: /submitEmail.php
  static_files: www/submitEmail.php
  upload: www/submitEmail.php

- url: /(.*)
  static_files: www/\1
  upload: www/(.*)

编辑 1 所以我最初为处理程序尝试了以下内容:

handlers:
-url: /(.+\.php)$
script: www/\1

-url: /
script: www/index.html

-url: /(.*)
script: www/\1

然而,简而言之,这是一场灾难。刷新后图像和 CSS 未加载。我想要的只是submitEmail.php当用户单击表单中的提交时执行index.html

为了澄清这是我的高级结构:

www/
-index.html
-submitEmail.php
app.yaml

编辑 2 当前状态,app.yaml但是当我提交表单时,我收到 404 错误。

handlers:
-url: /(.+\.php)$
script: www/\1

-url: /submitEmail.php

脚本:www/submitEmail.php

-url: /
script: www/index.html

-url: /(.*)
script: www/\1

标签: phpgoogle-app-engineyaml

解决方案


好吧,PHP 代码已交付,因为您将其声明为static_files. 静态文件在请求时按原样交付给客户端。

像这样更改您的处理程序:

- url: /submitEmail.php
  script: www/submitEmail.php
  upload: www/submitEmail.php

另请参阅app.yaml 参考


推荐阅读