首页 > 解决方案 > 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

标签: phpgoogle-app-enginegcloud

解决方案


404 的原因是您没有与路径app.yaml匹配的模式的处理程序。/forums/whatever.php您需要添加一个。

我建议使用home.php涵盖app.yaml 示例中任何 php 脚本路径的通用模式更改您现在拥有的脚本:

# Serve php scripts.
- url: /(.+\.php)$
  script: \1

如果您还想为空路径设置默认处理程序,则需要单独添加:

- url: /
  script: index.php

推荐阅读