[英]How to run php script on Google App Engine?
我在 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 文件。 我當前的應用程序.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
匹配的第一個處理程序是/(.*)
,它是 static 文件處理程序,因此它只返回您的 PHP 文件(不執行)
您希望它在匹配/(.*)
之前匹配(.+\.php)$
,因此您需要在處理程序列表中切換這兩個的順序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.