php - gcloud应用引擎中的子文件夹?
问题描述
基本上我想在我的网站上使用我的应用引擎 PHP 项目。当我将一个文件放在我的主文件夹中但我想在我的网站上使用子目录时它可以工作。例如,如果我想要一个论坛,我会将网址设为https://example.com/forums/whatever.php。相反,我在我的主文件夹中创建子目录,当我访问上面列出的目录时,它只会给我一个 404 not found (nginx) 错误。
这是我的 app.yaml 文件:
runtime: php55
api_version: 1
handlers:
- url: /index
static_dir: index
- url: /static
static_dir: static
- url: /index/.*
script: home.php
解决方案
404 的原因是您没有与路径app.yaml
匹配的模式的处理程序。/forums/whatever.php
您需要添加一个。
我建议使用home.php
涵盖app.yaml
示例中任何 php 脚本路径的通用模式更改您现在拥有的脚本:
# Serve php scripts. - url: /(.+\.php)$ script: \1
如果您还想为空路径设置默认处理程序,则需要单独添加:
- url: /
script: index.php
推荐阅读
- c# - 我将如何连接到提供证书文件 (.ovpn) 然后还指定用户名和密码的 VPN?
- angular - 使用 get() 后如何在 html 中显示 firestore 集合的文档数据
- android - 如何转储前台 Android 活动的 XML 布局(没有 uiautomator)?
- python-3.x - 如何在谷歌云构建中运行 REST API 来构建触发器
- angular - 如何禁用垫单选按钮的焦点?
- python-3.x - Python 在 curl 中请求等效于“--proxy-header”的 SSL 认证
- angular - 内置指令、属性指令和结构指令有什么区别?
- xamarin.forms - 无法从代码中创建的数据模板获取父绑定上下文
- javascript - 浏览器上的 JavaScript 模块
- android - Gson 不将值分配给直接内部对象,但如果我使用数组,它会分配值