nginx 判断跳转

nginx 判断跳转

配置文件中 识别移动端跳转

if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry))
{
rewrite  ^(.*)$  https://****.cn/index.php  permanent;
}			

配置文件中 识别蜘蛛跳转

if ($http_user_agent ~ "Baiduspider|360Spider|bingbot|Googlebot|Sogou web spider" )
{
rewrite  ^(.*)$  https://baidu.com/index.php  permanent;
}			

设置只允许蜘蛛访问,访客404

f ($http_user_agent !~* "Baidu|Yisou|Sogou|Google|360")
{
return 404;
}

设置只允许蜘蛛访问,访客浏览器跳转301

 if ($http_user_agent !~* "Baidu|Yisou|Sogou|Google|360")
{
   return 301 http://www.hao123.com;
}

设置只允许蜘蛛访问,访客浏览器跳转302

if ($http_user_agent !~* "Baidu|Yisou|Sogou|Google|6531.22.7")
{
return 302 http://www.baidu.com;
}
# 宝塔   Nginx  

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×