背景
- app 的推广页需要有一个下载链接,方便用户点击的时候直接下载 app,但是不同的系统下载的地方不一样;
方案
通过 userAgent 判断具体是哪个系统,是否在微信内打开,然后通过调整 respones 解决;
- 通过 node 服务
- 通过 Nginx
以上两种方式都可以解决这个问题,基于一些环境原因,选择用 Nginx 的方式去解决
Nginx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| server { listen 80; server_name www.a.com a.com; charset utf-8;
location /applink { if ($http_user_agent ~* "micromessenger" ){ rewrite ^/.* https://a.com/ulink/action/ redirect; } if ($http_user_agent ~* "android"){ rewrite ^/.* https://a.com/apk/appname.apk redirect; }
if ($http_user_agent ~* "iphone"){ rewrite ^/.* https://apps.apple.com/cn/app/ redirect; } rewrite ^/.* http://lizhifm.cn/d redirect; }
}
|