Android Deep Link配置:指定URL跳转并排除特定路径
Android Deep Link特定URL跳转配置修改方案
当前你的intent filter配置匹配了https://www.example.com/talks/下的所有路径,要实现仅允许指定两个URL跳转、排除view_all.aspx的需求,可按以下方式修改:
方案一:精确匹配固定路径
如果目标URL的路径完全固定(结尾斜杠一致),直接使用android:path指定精确路径:
<intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" /> <data android:host="www.example.com" /> <data android:path="/talks/item1-chat/" /> <data android:path="/talks/item2-chat/" /> </intent-filter>
方案二:灵活匹配路径(支持结尾斜杠可选)
如果目标URL可能存在结尾斜杠省略的情况,使用android:pathPattern做模糊匹配:
<intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" /> <data android:host="www.example.com" /> <data android:pathPattern="/talks/item1-chat.*" /> <data android:pathPattern="/talks/item2-chat.*" /> </intent-filter>
说明
- 两种方案都会只匹配符合规则的两个目标URL,
https://www.example.com/talks/view_all.aspx因不满足任何路径匹配条件,会被自动排除,不会触发应用跳转。 - 保留
android:autoVerify="true"需确保域名根目录已正确配置assetlinks.json文件,这部分你已实现正常跳转,无需额外调整。
内容的提问来源于stack exchange,提问作者Nensi Kardani
相关产品推荐
相关产品推荐

