使用 PHP Yii2 框架的 google 應用引擎中出現 404 錯誤

使用 PHP Yii2 框架的 google 應用引擎中出現 404 錯誤

我的應用程式包含 Angular 和 Php Yii2 框架。

我將我的應用程式託管到Google雲端平台的應用程式引擎上。

這是我的程式碼和 app.yaml 檔案代碼的螢幕截圖。

threadsafe: true
runtime: php55
api_version: 2

handlers:

# The root URL (/) is handled by the Go application.
# No other URLs match this pattern.

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

- url: /web-service/*
  script: web-service/yii

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

在此輸入影像描述

我的 Yii2 庫可在 web-service direcotry 中使用,當我從郵遞員呼叫rest api 時,它會傳回 404 頁面未找到錯誤。

我的文件中缺少什麼東西app.yaml

幫我解決這個問題。

我的 Api 是這樣稱呼的。

https://abcxyz.appspot.com/web-service/web/user-registration/login-user

答案1

您的 URL 處理程序的順序不正確。

GAE 從上到下執行這些操作。您的第一個處理程序將符合所有內容。它永遠不會到達另外兩個。

您需要更改 app.yaml 中的順序:

threadsafe: true
runtime: php55
api_version: 2

handlers:

# The root URL (/) is handled by the Go application.
# No other URLs match this pattern.

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

- url: /web-service/*
  script: web-service/yii

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

建議始終將最廣泛的放在底部,將最嚴格的放在頂部。

請參閱 GAE app.yaml 文件中的相關部分。

相關內容