Skip to content

Instantly share code, notes, and snippets.

@GiaoGiaoCat
Last active April 5, 2017 23:29
Show Gist options
  • Save GiaoGiaoCat/eb119ae11b0d5f80d626c2bd51549dc9 to your computer and use it in GitHub Desktop.
Save GiaoGiaoCat/eb119ae11b0d5f80d626c2bd51549dc9 to your computer and use it in GitHub Desktop.
nginx rewrite spider
## 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