gpt4 book ai didi

javascript - 如何在 Firebase 托管中处理动态 URL 路由

转载 作者:行者123 更新时间:2023-12-03 09:35:43 26 4
gpt4 key购买 nike

因此,假设在 Firebase 的公用文件夹中,我有一个 index.htmlsalon.html .

现在获取像 xyz.com/salon/43 这样的网址我要加载salon.html在 javascript 中,我想从实时数据库中获取沙龙 43。

现在我可以拥有像 xyz.com/salon?id=43 这样的网址.我想知道是否可以在 Firebase 托管中进行前者,如果可以的话。

最佳答案

您正在寻找 Firebase 托管重写。来自 documentation :

Use a rewrite when you want to show the same content for multiple URLs. Rewrites are particularly useful with pattern matching, as you can accept any URL that matches the pattern and let the client-side code decide what to display. Rewrite rules can be used to support apps using HTML5 pushState for navigation. When a browser attempts to open a specified source URL it will be given the contents of the file at the destination URL.

URL rewrites can be specified by defining a rewrites section within hosting in the firebase.json file:

"hosting": {
// Add the "rewrites" section within "hosting"
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ]
}

关于javascript - 如何在 Firebase 托管中处理动态 URL 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44261372/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com