在server {} 块中添加下面的配置

 

    location =/robots.txt {
        default_type text/html;
        add_header Content-Type "text/plain; charset=UTF-8";
        return 200 "User-Agent: *\nDisallow: /";
    }

 

在线测试robots.txt是否生效

https://ziyuan.baidu.com/robots/index

 

robots.txt文件生产工具:http://tool.chinaz.com/robots/

 

其他网站参考:

https://www.tmall.com/robots.txt

https://www.jd.com/robots.txt

https://www.qq.com/robots.txt

 

相关文章:

  • 2021-12-04
  • 2021-05-28
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
  • 2021-08-31
相关资源
相似解决方案