php - 如何从 Google App Engine Standard 上的 CI 应用程序的子目录运行自定义 php 应用程序?
问题描述
我对如何设置 app.yaml 以完成我的工作感到有些困惑。以前,我在其他地方运行了相同的 codeigniter 应用程序,其/support
子目录为自定义 php 支持台应用程序提供服务。它没有问题。Good 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/\1/\2.php
- url: /support/(.*)\.php$
script: support/\1.php
但问题是这个东西有很多子文件夹。请参阅 support/inc 文件夹下方的此快照。如何处理?我是否必须为所有可能的子目录级别手动放置一个 url-script 对?这太令人沮丧了!
解决方案
您将每个呼叫发送- url: /support/.*
到index.php
。你想要的是一个正则表达式发送到正确的脚本:
- url: /support/(.+).php
script: support/\1.php
注意:您的app.yaml
andindex.php
位于support
目录内。您将需要app.yaml
在根目录下,否则您将无法访问支持目录之外的文件。是support
这个应用程序的根吗?
记住:url 是相对于app.yaml
文件的
对于根级别的文件,您将使用:
- url: /(.+).php
script: \1.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/\1
upload: support/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
application_readable: true
推荐阅读
- sql - PGSQL ROLLUP 函数不存在
- javascript - useSWR 令牌传递部分存在类型错误
- r - 如何使用 for 循环命令?
- excel - Excel:其他两次之间的轮班时间
- r - 使用 mutate 添加一个关系在另一个表中的新键。Tidyverse/润滑/R
- python - 在烧瓶中工作的Web应用程序在应用程序引擎上不稳定
- java - S3 预签名 URL 上传 - 我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签名方法
- flutter - 是否可以将进度条作为指示器而不是带有图像滑块轮播的点指示器?
- ios - iPadOS 中的 Vue JS 生命周期可防止警报
- python - 修改代码以使用与上传的 CSV 不同的列中的字符替换数字