Skip to content

Instantly share code, notes, and snippets.

@KABBOUCHI
Forked from vladkras/default.conf
Created November 6, 2019 09:35
Show Gist options
  • Save KABBOUCHI/024907fd804648417956b5e490fc4eda to your computer and use it in GitHub Desktop.
Save KABBOUCHI/024907fd804648417956b5e490fc4eda to your computer and use it in GitHub Desktop.
NGINX redirect to app store and google play based on user agent
location = /gotoapp {
if ($http_user_agent ~* "iphone|ipod|ipad|appletv") {
return 301 https://www.apple.com/lae/ios/app-store/;
}
if ($http_user_agent ~* "android") {
return 301 https://play.google.com/store;
}
if ($http_user_agent ~* "Windows") {
return 301 https://www.microsoft.com/store/apps?rtc=1;
}
if ($http_user_agent ~* "Linux") {
return 301 https://www.linux.org/;
}
if ($http_user_agent ~* "Mac") {
return 301 https://www.apple.com/mac/;
}
return 301 /cant-detect;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment