如何从 Google App Engine Standard 上的 CI 应用程序的子目录中获取自定义 php 应用程序 运行?

How to get a custom php application run from a subdirectory of a CI application on Google App Engine Standard?

我对如何设置 app.yaml 以完成我的工作感到有点困惑。以前我在其他地方有这个相同的 codeigniter 应用程序 运行,其中 /support 子目录服务于自定义 php 支持桌面应用程序。它没有问题。好的 ol'apache 没有任何问题。

现在我想在 GAE 上做同样的事情!这是我的 app.yaml

application: <NAME>
version: 1
runtime: php55
api_version: 1
threadsafe: yes

handlers:

- url: /assets
  static_dir: assets

- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /support/.*
  script: index.php

- url: /.*
  script: index.php
  secure: always

只是为了确保在有人向我提供解决方案后我正确地路由了所有文件。这是支持台的目录结构(称为 hesk)-

我需要一个带通配符的解决方案,以便 /support 可以完美地处理子文件夹和所有内容.. 还需要定义静态文件。如您所见,它们散落在各处……一点也不方便,但就是这样!我不擅长正则表达式。所以请怜悯我。

更新: 我添加了更新 app.yaml 一点.. 现在支持根目录和第一级子目录中的所有 php 脚本工作

- url: /support/(.*)/(.*)\.php$
  script: support//.php

- url: /support/(.*)\.php$
  script: support/.php

但问题是这个东西里有很多子文件夹。请参阅 support/inc 文件夹下方的这张快照。如何处理?我是否必须为所有可能的子目录级别手动放置一个 url-script 对?这太令人沮丧了!

您正在将对 - url: /support/.* 的每个呼叫发送到 index.php。您想要的是发送到正确脚本的正则表达式:

- url: /support/(.+).php
  script: support/.php

注意: 您的 app.yamlindex.php 位于 support 目录中。您需要在根目录下使用 app.yaml,否则您将无法访问支持目录之外的文件。 support 是这个应用程序的根目录吗?

记住:url 是相对于 app.yaml 文件

对于根级别的文件,您将使用:

- url: /(.+).php
  script: .php

您需要将静态文件放在静态目录中,并使用:

- url: /static
  static_dir: static

并使用以下方式访问文件,例如:/static/hesk_javascript.js

更新 2 使用正则表达式处理静态文件:

- url: /support/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
  static_files: support/
  upload: support/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
  application_readable: true

解决方案: 谢谢 GAEfan .. 我有点混合了你的想法,最后这些是需要的处理程序。现在 运行 太棒了!

#for all the static files residing at support root or at any other level
- url: /support/(.*\.(htm$|css$|js$|ico$|jpg$|png$|gif$))$
  static_files: support/
  upload: support/.*\.(htm$|css$|js$|ico$|jpg$|png$|gif$)$
  application_readable: true

#for all the php files running at support root or at any other level
- url: /support/(.+)\.php
  script: support/.php

#for using index.php at support root or at any other level
- url: /support/(.*)
  script: support//index.php

P.S : 下面的处理程序可以从任何其他级别 运行 index.php 但不支持 root

- url: /support/(.+)
  script: support//index.php