在Google App Engine Standard中配置嵌套的静态文件夹 - PHP环境

时间:2018-02-25 15:44:53

标签: php google-app-engine server google-cloud-platform app.yaml

我有以下文件结构:

  • public / index.html
  • public / css / style.css
  • public / images / bg.jpg
  • public / app / index.html
  • public / app / style.css
  • public / app / bundle.js

部署后,我可以毫无问题地访问root中的index.html

但文件夹 app 中的index.html会为所有 css js 文件提供404错误。

如何在 app.yaml 配置中正确配置应用文件夹资源。

这是我的app.yaml:

runtime: php55
api_version: 1
threadsafe: true

skip_files: 
- src/
- node_modules/
- ^(.*/)?#.*#
- ^(.*/)?.*~
- ^(.*/)?.*\.py[co]
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*

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

- url: /app/.*
  static_files: public/app/index.html
  upload: public/app/index.html

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

1 个答案:

答案 0 :(得分:1)

那是因为根据匹配这些文件的处理程序,您正在上传public/app/index.html而不是相应的文件:

- url: /app/.*
  static_files: public/app/index.html
  upload: public/app/index.html

您应该更改处理程序以上传相应的文件,请参阅Handlers element表中的 static_files 行:

- url: /app/(.*\.(html|js|css))$
  static_files: public/app/\1
  upload: public/app/.*\.(html|js|css)$