Nginx location robots.txt

来自Linux78|wiki
Bob讨论 | 贡献2020年3月13日 (五) 16:13的版本 (创建页面,内容为“ location =/robots.txt { root /data/wwwroot/xxx.com/; #单独rewrite一个文件要设置index等于这个文件 index robots.txt; } location =/ro…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
location =/robots.txt {
    root /data/wwwroot/xxx.com/;
    #单独rewrite一个文件要设置index等于这个文件
    index robots.txt;
 }
location =/robots.txt {
       default_type text/html;
       add_header Content-Type "text/plain; charset=UTF-8";
       return 200 "User-Agent: *\nDisallow: /";
   }
location = /robots.txt {
   if ($http_user_agent !~* "spider|bot|yahoo|sogou") {
       return 404;
   }
}