Forked from Ara4Sh/gist:863e4796801f0453460faddb78e0ea62
Created
January 31, 2018 17:35
-
-
Save jamesnguyen101/14b8b48cf338e3f2233e77669c959d38 to your computer and use it in GitHub Desktop.
Nginx Redirect if useragent is android or iphone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1 | |
location / { | |
set $mobile 0; | |
if ($http_user_agent ~* "iphone|android") { | |
set $mobile 1; | |
} | |
if ($mobile = 1) { | |
# return or rewrite to somewhere | |
} | |
} | |
# 2 | |
location / { | |
try_files $uri @mobile; | |
} | |
location @mobile { | |
set $mobile 0; | |
if ($http_user_agent ~* "iphone|android") { | |
set $mobile 1; | |
} | |
if ($mobile = 1) { | |
# return or rewrite to somewhere | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment