Created
March 26, 2017 07:51
-
-
Save Ara4Sh/863e4796801f0453460faddb78e0ea62 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