android - nginx 从 Web 重定向到移动应用程序

标签 android ios redirect nginx uri

有 Android 和 iOS 应用程序,我有动态 URI,我需要通过 nginx 将 Android 和 iOS 用户直接重定向到移动应用程序,前提是他们使用此链接。 但是我不明白没有“逻辑与”或“内部如果”如何处理。

据我所知,我必须解决两个条件:

if ($http_user_agent ~* '(iphone|ipod|nokia|аndroid)' ) {
  rewrite ^ mobile_application://$host$request_id last;
}

和:

set $my_uri sign-up?invitation=$key #this key is dynamical
if ($request_id = '($my_uri)' ) {
      rewrite ^ mobile_application://$host$request_id last;
    }

所以,我不知道如何修复它。

最佳答案

set $targeted_mobile no;
  if ($http_user_agent ~* "android|iphone|ipod") {
    set $targeted_mobile yes;
  }

  location /deep-link/ {
    if ($targeted_mobile = yes) {
      rewrite ^/deep-link/(.*) mobile://www.aaa.com/$1 permanent;
    }
    rewrite ^/deep-link/(.*) https://$server_name/$1 permanent;

关于android - nginx 从 Web 重定向到移动应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27040571/

相关文章:

ios - 如何添加实例变量并在自定义 UIButton 中使用它

apache - 带有查询字符串的htaccess RewriteRule页面

android - 在 appcompat-v7 的工具栏中删除标题

ios - 如何推送不在导航 Controller 中的 View Controller ? swift

ios - 存档时,Facebook调整了CocoaPods链接器错误

apache - 我可以使用 HTACCESS 来格式化此 URL 吗?

.htaccess - 在 Drupal 中,如何使用 .htaccess 从 ?q= 重定向到干净的 URL?

android - 通过电子邮件从 Android 应用程序发送数据

java - 使用 kotlin 在菜单中制作可点击的链接

android - Camera2 可以连续访问相机预览图像