简体   繁体   English

重写 firebase.json 的规则以配置 firebase 托管

[英]Rewrite Rules for firebase.json to configure firebase hosting

I am developing a web app and hosted all files on Firebase Hosting.我正在开发一个 web 应用程序并将所有文件托管在 Firebase 托管上。

As of now my page URL looks like截至目前,我的页面 URL 看起来像

mydomain.com/user/index.html?user=username

but when I enter但是当我进入

mydomain.com/username

It should behave same.它的行为应该相同。 What should be the rules?应该有什么规则?

I tried this but not working我试过这个但不工作

{
  "hosting": {
    "public": "psNew4",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "redirects": [ {
    "source": "/user/index.html?user=:username", // username is dynamic
    "destination": "https://example.com/:username",
    "type": 301
  }]
  }
}

PS: username is dynamic PS: username是动态的

Is there any solution for this or not?有没有解决方案?

According to the Firebase documentation on capturing URL segments for redirects you're looking for something like this:根据关于捕获 URL 段以进行重定向的 Firebase 文档,您正在寻找这样的东西:

"hosting": {
  // ...

  "redirects": [ {
    "source": "/user/index.html?user=:username",
    "destination": "https://example.com/:username",
    "type": 301
  }]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM