如何从单页面应用程序重写中排除路径(/ images)?

时间:2018-01-06 15:22:56

标签: firebase firebase-hosting

我有一个反应应用程序,并且在firebase托管中有通常的重写规则:

   "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]

我还有一个单独的/ images目录,其中包含我不想重写的图像。

如何从重写中排除/ images目录?

2 个答案:

答案 0 :(得分:2)

我来晚了,但是在寻找类似问题时发现了这个问题。

使用此重写规则:

"rewrites": [
  {
    "source": "!/images/**",
    "destination": "/index.html"
  }
]

关键是“源”(如firebase.json中的许多字段)使用glob pattern matching notation。 该规则不会重定向index.html上的所有内容(“ **”也一样),而是重定向图像文件夹和子文件夹中所有的内容。

答案 1 :(得分:-1)

"hosting": {
  "rewrites": [
    {
      "source": "/images/**",
      "destination": "/something.html"
    },
    {
      "source": "**",
      "destination": "/index.html"
    }
  ]
}

这将排除/images文件夹中的所有内容,将其重写为/something.html

相关问题