【问题标题】:Website Configuration on Google Cloud Storage without error pages谷歌云存储上的网站配置没有错误页面
【发布时间】:2014-08-02 10:46:55
【问题描述】:

我正在(尝试)在 Google Cloud Storage 上托管一个单页应用程序。

应用程序位于 index.html,应用程序使用 Angular 的 html5Mode 处理路由。 (例如:由 index.html 中的 js 应用程序处理的 example.com/this 和 example.com/ 等路由)

使用 Google Cloud Storage 的网站配置,这一切都很好,除了直接访问的路由(“example.com/this”)将 404,因为它们显然没有映射到文件.

我已将我的 404 页面设置为我的索引页面,但为了在 html5Mode 中运行单页应用程序,我真正需要的是此类路由(“example.com/this”)不会返回 404 标头 -它们将简单地由 index.html 处理并返回成功标头 (200)。

这可能吗?

【问题讨论】:

  • 我遇到了同样的问题,我可以使用 S3 作为替代方案并使用redirection rules

标签: html angularjs single-page-application google-cloud-storage pushstate


【解决方案1】:

现在从网站配置中将 index.html 设置为您的 404 页面似乎可以解决问题。

【讨论】:

  • 不知道为什么这被否决了,因为用户非常友好地不发表评论,但这对我来说非常有效。
【解决方案2】:

不幸的是,这实际上是不可能的。 Google Cloud Storage 的网络映射非常简单,您无法根据模式等创建任意规则。

您可能需要考虑禁用 html5mode 或使用 html5mode 强制使用 hashbang。有关该选项的更多信息,请参阅this answer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-10
    • 1970-01-01
    • 2023-03-26
    • 2012-10-15
    • 2016-04-12
    • 1970-01-01
    • 2016-02-29
    • 1970-01-01
    相关资源
    最近更新 更多