Skip to content

Instantly share code, notes, and snippets.

@TornadoRadon
Forked from vladkras/default.conf
Created January 17, 2024 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TornadoRadon/7aa135c5562432f69ab0c83778eb1103 to your computer and use it in GitHub Desktop.
Save TornadoRadon/7aa135c5562432f69ab0c83778eb1103 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