允许特定网址格式
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
为防止未经授权的各方使用您的 API 密钥创建 Dynamic Links,从您的网域重定向至您不拥有的网站,您应指定 Dynamic Links 可重定向到的网址。
如需指定允许的网址,请在 Firebase 控制台的 Dynamic Links 页面中依次点击 more_vert > 许可名单网址格式,然后使用 RE2 语法指定最多 10 个正则表达式。只有与这些正则表达式之一匹配的网址才能成功用作 Dynamic Links 的深层链接 (link
) 或后备链接(afl
、ifl
、ipfl
、ofl
)。如果您指定了网址格式,则任何与其中一种格式不匹配的网址都将导致 Dynamic Links 返回 HTTP 错误 400。
您应尽可能严格地设置网址格式。例如:
过于宽松 |
更好 |
^https://.*.com/.*$
可以重定向到以 .com 结尾的任何网站上的任何页面。
|
^https://mybrand\.com/.*$
只能重定向到 mybrand.com 上的页面。
|
^https://play.google.com/.*$
可以重定向到任意应用的 Google Play Store 页面。
|
^https://play\.google\.com/.*id=myapp\.com$
只能重定向到软件包名称为 myapp.com 的应用的 Google Play Store 页面。
|
^https://itunes.apple.com/.*$
可以重定向到 itunes.apple.com 上的任何页面。
|
^https://itunes\.apple\.com/.*id123$
只能重定向到 ID 为 id123 的应用的应用商店页面。
|
您可以查看 Dynamic Links 的调试页面并核实没有任何警告,从而确保 Dynamic Links 的深层链接和后备链接与您的某个网址格式相匹配:
https://example.page.link/WXYZ?d=1
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-18。
[null,null,["最后更新时间 (UTC):2025-08-18。"],[],[],null,["\u003cbr /\u003e\n\n| **Deprecated:** Firebase Dynamic Links is *deprecated* and should not be adopted in projects that don't already use it. The service will shut down on August 25, 2025. See the [Dynamic Links Deprecation FAQ](/support/dynamic-links-faq) for more information.\n\nTo prevent unauthorized parties from using your API key to create Dynamic Links that\nredirect from your domain to sites you don't own, you should specify the URLs\nyour Dynamic Links can redirect to.\n\nTo specify the allowed URLs, click\nmore_vert **\\\u003e Allowlist URL pattern**\nfrom the Dynamic Links page of the Firebase console, and then specify up to\n10 regular expressions using\n[RE2 syntax](https://github.com/google/re2/wiki/Syntax). Only URLs\nthat match one of these regular expressions can be successfully used as a deep\nlink (`link`) or fallback link (`afl`, `ifl`, `ipfl`, `ofl`) for a Dynamic Links. If\nyou specify URL patterns, any URL that doesn't match one of the patterns will\ncause your Dynamic Links to return HTTP error 400.\n\nYou should make your URL patterns as restrictive as possible. For example:\n\n| Too permissive | Better |\n|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|\n| `^https://.*.com/.*$` Can redirect to any page on any site ending with `.com`. | `^https://mybrand\\.com/.*$` Can redirect only to pages at `mybrand.com`. |\n| `^https://play.google.com/.*$` Can redirect to any app's Google Play Store page. | `^https://play\\.google\\.com/.*id=myapp\\.com$` Can redirect only to Google Play Store pages for the app with the package name `myapp.com`. |\n| `^https://itunes.apple.com/.*$` Can redirect to any page on `itunes.apple.com`. | `^https://itunes\\.apple\\.com/.*id123$` Can redirect only to the App Store page for the app with the ID `id123`. |\n\nYou can make sure a deep link and fallback links for a Dynamic Links match one of\nyour URL patterns by viewing the debug page for Dynamic Links and verifying there are\nno warnings: \n\n```\nhttps://example.page.link/WXYZ?d=1\n```"]]