nginx通过robots.txt禁止所有蜘蛛访问(禁止搜索引擎收录)


在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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM