Last active
April 29, 2021 20:08
-
-
Save wokamoto/9340462 to your computer and use it in GitHub Desktop.
[Nginx] mobile-detect
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
set $mobile ''; | |
set $mobile_off ''; | |
if ($http_user_agent ~* '(DoCoMo|J-PHONE|Vodafone|MOT-|UP\.Browser|DDIPOCKET|ASTEL|PDXGW|Palmscape|Xiino|sharp pda browser|Windows CE|L-mode|WILLCOM|SoftBank|Semulator|Vemulator|J-EMULATOR|emobile|mixi-mobile-converter|PSP)') { | |
set $mobile "@ktai"; | |
} | |
if ($http_user_agent ~* '(iPhone|iPod|incognito|webmate|Android|dream|CUPCAKE|froyo|BlackBerry|webOS|s8000|bada|IEMobile|Googlebot\-Mobile|AdsBot\-Google)') { | |
set $mobile "@smartphone"; | |
} | |
if ($http_cookie ~* "wptouch[^\=]+\=(normal|desktop)") { | |
set $mobile_off "${mobile}.off"; | |
} | |
if ($mobile_off = "@smartphone.off") { | |
set $mobile "@smartphone.off"; | |
} | |
location ~* @(ktai|smartphone|smartphone\.off)$ { | |
access_log /dev/null; | |
log_not_found off; | |
return 404; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment