【问题标题】:Handle deep linking with multiple redirection使用多重重定向处理深度链接
【发布时间】:2021-03-24 23:59:17
【问题描述】:

我有一个安卓应用。尝试使用具有多个重定向的深层链接。
第一个。重定向 - 当我打开这个 url (https://www.tiny.com/op/abRh4) Nginx 把这个 URL 重定向到 http://customdomain.com/internal

第二次重定向 - 此 Url (http://customdomain.com/internal/abRh4) 将自动(通过 API)重定向到 https://customdomain.com?screen-no=25&notification=show(长 url)

我终于想打开与https://customdomain.com?screen-no=25&notification=show 的深层链接。但是android用http://customdomain.com/internal/abRh4打开它

有人建议如何使用深度链接处理多个重定向(我们可以通过 nginx 配置将这个多个重定向处理成单个重定向吗)?

这是两个不同的服务器(第一个服务器 -> Nginx 重定向,第二个服务器 -> api 命中的位置)

nginx 配置

server {
        listen 443 ssl http2;
        server_name www.tiny.com;
        location /op {
        add_header 'Access-Control-Allow-Origin' '*' always;
                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass https://customdomain.com/internal;
    }
}

    //this api will hit when we call http://customdomain.com/internal/abRh4

    @GET
    @Path("/{shortKey}")
    @Produces({MediaType.TEXT_HTML})
    public Response resolveShortUrl(@PathParam("shortKey") String shortUrlKey) {

        UrlShortenerLogicHelper helper = new UrlShortenerLogicHelper();
        try {
            helper.openConnection();
            URI url = new URI(helper.resolveShortUrl(shortUrlKey));
            // return url like https://customdomain.com?screen-no=25&notification=show
            return Response.temporaryRedirect(url).build();
        } catch(Exception e){}
    }


【问题讨论】:

  • 显示一些代码,您当前如何实现深度链接以及WebView 初始化。如果第一个重定向有效,为什么第二个不应该...
  • @snachmsm 添加一些代码。可能这会有所帮助

标签: android nginx redirect


【解决方案1】:

您可以在活动的意图过滤器中添加多个数据标签

<data android:host="www.test.com"
 android:pathPrefix="/op/abRh4"
 android:scheme="https" />

<data android:host="www.myOwnSite.com"
 android:pathPrefix="/shorturl/abRh4"
 android:scheme="https" />

【讨论】:

  • 感谢您的回复。抱歉,我更改了域名以获得更清晰的解释。你能帮忙吗?我也添加了一些代码来理解
猜你喜欢
  • 1970-01-01
  • 2020-07-14
  • 2018-07-17
  • 2013-09-12
  • 1970-01-01
  • 1970-01-01
  • 2018-04-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多