php - 如何在 Google App Engine 上运行 php 脚本?
问题描述
我在 Google App Engine 环境中遇到了一个 php 脚本问题。
我尝试使用 ajax 调用调用 php 脚本,但成功回调总是返回未处理的 php 文件(<?php .... ?>
)
ajax 调用如下所示:
$.ajax({
type: "POST",
url: "/contactform-process.php",
data: "name=" + name + "&email=" + email + "&message=" + message + "&terms=" + terms,
success: function(text) {
console.log('Hello')
if (text == "success") {
cformSuccess();
} else {
cformError();
csubmitMSG(false, text);
}
}
});
我假设我必须声明 Google App Engine 环境正在正确处理 php 文件。我当前的 app.yaml:
runtime: php74
handlers:
- url: /
static_files: static/index.html
upload: static/index.html
- url: /de
static_files: static/de/index.html
upload: static/de/index.html
- url: /en
static_files: static/en/index.html
upload: static/de/index.html
- url: /(.*)
static_files: static/\1
upload: static/(.*)
- url: /(.+\.php)$
script: auto
- url: /contactform-process.php
script: auto
有谁知道缺少什么,所以 php 文件以正确的方式处理?
解决方案
/contactform-process.php
匹配的第一个处理程序是/(.*)
,它是一个静态文件处理程序,因此它只是按原样返回您的 PHP 文件(不执行它)。
您希望它在匹配(.+\.php)$
之前匹配/(.*)
,因此您需要在处理程序列表中切换这两个的顺序。
推荐阅读
- http - 查尔斯无法在某些计算机上捕获本地桌面 HTTP 请求
- python-3.x - 葡萄酒质量数据集分析
- r - R中的数据操作,处理时间更短
- c# - 当动态按钮随机分布时,如何防止它们重叠?
- scope - While without global
- python - 将 PIL.Image 转换为 wagtailimages.Image
- css - 模块构建失败:TypeError:无法读取未定义的属性“sassLoader”
- python - 如何在python中将字符串转换为元组
- amazon-web-services - 基于查询字符串的 AWS 负载平衡 (ALB)
- bash - 总结unix中的多个文件