2

我有一个指向“项目详细信息”页面的 URL 结构,如下所示:(john/project/eRdKn6其中“john”是用户名,“eRdKn6”是项目 ID)。我希望将其重写到文件project.html中,在其中解析 document.location 并加载适当的数据。所以用户名和项目ID应该是动态的。

我的规则firebase.json如下所示:

{
  "source": "*/project/*",
  "destination": "/project.html"
}

但是,当我尝试加载 Firebase 404 时http://example.com/john/project/eRdKn6

我试图只使最后一部分动态化,作为测试(例如{"source": "john/project/*", "destination": "/project.html"},但我也得到了 404.

project.html是在文件public夹中。

这是我的完整firebase.json文件:

{
  "firebase": "example",
  "public": "public",
  "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
  ],
  "rewrites": [
    {"source": "*/project/*", "destination": "/project.html"}
  ]
}
4

1 回答 1

2

似乎问题在于source需要一个起始斜线,例如/*/project/*. 我的完整firebase.json现在看起来像这样:

{
  "firebase": "example",
  "public": "public",
  "ignore": [
    "firebase.json",
    "**/.*",
    "**/node_modules/**"
  ],
  "rewrites": [
    {"source": "/*/project/*", "destination": "/project.html"}
  ]
}

这似乎是一个文档问题,因为没有一个示例涵盖此用例。

于 2016-02-06T15:07:56.073 回答