Nginx 限制php解析、限制浏览器访问

限制php解析
1、有时候会根据目录来限制php解析:
location ~ .*(diy|template|attachments|forumdata|attachment|image)/.*.php$ 
{
        deny all;
}

限制浏览器访问

 1、使用 user_agent 控制客户端浏览器访问 
location / {
    if ($http_user_agent ~ 'bingbot/2.0|MJ12bot/v1.4.2|Spider/3.0|YoudaoBot|Tomato|Gecko/20100315'){
            return 403;
    }
}

  

原文地址:https://www.cnblogs.com/xiangsikai/p/8394801.html