【问题标题】:google cloud platform host website, but only working for index.html谷歌云平台托管网站,但仅适用于 index.html
【发布时间】:2018-12-06 02:12:58
【问题描述】:

我想使用谷歌云平台来托管我的网站(有些文件只有 html,有些文件是 php)。但它只显示没有任何图像的 index.html 页面,并且所有链接都不起作用。我认为我的 app.yaml 文件不正确。

案例背景:

  • 我在我的 mac 中使用 google cloud sdk。
  • gcloud app deply(这是部署我的网站的命令)

这里有 app.yaml 文件:

runtime: php55
api_version: 1

handlers:

- url: /.*
  script: index.html

【问题讨论】:

    标签: google-cloud-sdk


    【解决方案1】:

    您需要在 app.yaml 中将 static_dir or static_files elements 添加到处理程序。

    以static_dir为例:

    runtime: php55
    api_version: 1
    
    handlers:
    
    - url: /
      script: index.html
    - url: /images
      static_dir: images

    【讨论】:

    • 感谢您的回答,但我遵循您为图像所做的工作。它不起作用。我只在 images 文件夹中放了 1 个 jpg 文件。我的网站在 cpanel 服务器中正常工作。它只在谷歌云中有问题。我认为我的 app.yaml 文件不正确。
    • 我已经用完整的例子编辑了答案。从 url 字段中删除“ .* ”对我有用。如果仍然不起作用,您可以分享您的 index.html 文件吗?
    猜你喜欢
    • 1970-01-01
    • 2020-08-30
    • 2021-12-20
    • 1970-01-01
    • 1970-01-01
    • 2020-06-02
    • 1970-01-01
    • 2020-02-08
    • 2020-08-06
    相关资源
    最近更新 更多