Nginx从Web重定向到移动应用程序 [英] nginx redirect from web to mobile application
本文介绍了Nginx从Web重定向到移动应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有Android和iOS应用程序,我具有动态URI,仅当他们使用此链接时,我才需要通过nginx将Android和iOS用户直接重定向到移动应用程序. 但是我不明白如果没有逻辑与"或内部条件",该如何处理.
There are Android and iOS applications, I have dynamical URI and I need to redirect Android and iOS users directly to mobile application via nginx, only if they use this link. But I don't understand how to handle it without "logical and" or "inner if".
据我了解,我必须解决两个条件:
As I understand I have to solve two conditions:
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;
}
所以,我不知道如何解决它.
So, I have no idea how to fix it.
推荐答案
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;
这篇关于Nginx从Web重定向到移动应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文