Last active
April 5, 2017 23:29
-
-
Save GiaoGiaoCat/eb119ae11b0d5f80d626c2bd51549dc9 to your computer and use it in GitHub Desktop.
nginx rewrite spider
This file contains hidden or 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
## rewrite spider | |
if ($http_user_agent ~* (baiduspider|googlebot|Googlebot|soso|bing|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot)) { | |
rewrite ^/(.*)$ https://www.baidu.com permanent; | |
} | |
## rewrite mobile | |
location /{ | |
set $mob 'y'; | |
if ($http_user_agent ~* "(Android|iPhone|Windows Phone)"){ set $mob "${mob}e"; } | |
if ($host != 'm.exp.com'){ set $mob "${mob}s"; } | |
if ($mob = "yes"){ rewrite ^/$ http://m.exp.com/$1 last; } | |
include /mnt/clouddisk/sync/web/rewrite.conf; #rewrite end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment