【问题标题】:Firebase redirect user to a new URL when they enter my website当用户进入我的网站时,Firebase 将用户重定向到新网址
【发布时间】:2020-08-29 21:54:12
【问题描述】:

我之前在 Firebase 上托管了我的网站,网址为:https://oldurl.firebaseapp.com/ 并且该应用程序已过时。

最近我更新了应用程序并决定尝试 Vercel,并在此 URL 上创建了我的网站实例:https://newurl.now.sh/

现在我不希望用户转到以前的 firebase 域并查看过时的应用程序。我想要的是将用户从 firebase 域重定向到新的 Vercel 域。

假设当用户访问这个 URL https://oldurl.firebaseapp.com/,我想将他们重定向到这个 URL:https://newurl.now.sh/

我该怎么做?

【问题讨论】:

  • 我可以访问我的 Firebase 设置

标签: firebase next.js vercel


【解决方案1】:

如果您想在用户进入您的网站时将其重定向到新的 URL,请编辑您项目的 firebase.json 文件,如下所示:

{
  "hosting": {
    "public": "build", //whatever your public directory is
    "redirects": [
      {
        "source": "/",
        "destination": "https://mynewurl.now.sh/",
        "type": 301
      }
    ]
  }
}

然后部署

我从 google firebase group 找到了这个解决方案

有关托管配置的更多信息,请访问https://firebase.google.com/docs/hostingConfigure redirects 部分介绍了重写(如代码 sn-p)。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2017-09-25
  • 1970-01-01
  • 2017-07-12
  • 2016-05-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多