[英]Load data on a single page based on the url
I have a single html file that I have linked to Firestore that I want to load public data on based on the URL (not url params).我有一个链接到 Firestore 的 html 文件,我想根据 URL(不是 url 参数)加载公共数据。
The url will be generated by the user from the slug parameter in my firestore:该 url 将由用户从我的 firestore 中的 slug 参数生成:
Domain.com/bobs-store
(slug = bobs-store) Domain.com/bobs-store
(slug = bobs-store)
Domain.com/sallys-boutique
(slug = sallys-boutique) Domain.com/sallys-boutique
(slug = sallys-boutique)
Domain.com/davidsgarage
(slug = davidsgarage) Domain.com/davidsgarage
(slug = davidsgarage)
Based on the url I want to load Firestore data (using the slug which I pull from the url).基于 url 我想加载 Firestore 数据(使用我从 url 中提取的 slug)。 I'm stumped on how to make the different urls all end up on the same index.html page regardless of the url without individual redirects.
我很困惑如何使不同的 url 最终都出现在同一个 index.html 页面上,而不管没有单独重定向的 url。
Where you are stuck (mapping multiple URLs to a single page) seems to have very little to do with Firestore, but mostly depends on the provider where you host your HTML pages.您卡在哪里(将多个 URL 映射到单个页面)似乎与 Firestore 几乎没有关系,但主要取决于您托管 HTML 页面的提供商。
If you're using Firebase Hosting, have a look at how to configure rewrites .如果您使用 Firebase 托管,请查看 如何配置 rewrites 。 For example, to map all URLs to the same
index.html
, that documentation shows this example:例如,要将所有 URL 映射到同一个
index.html
,该文档显示了以下示例:
"hosting": {
// ...
// Serves index.html for requests to files or directories that do not exist
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.