How to replace robots.txt with .htaccess

空扰寡人 提交于 2020-01-02 10:09:18

问题


I have a small situation where i have to remove my robots.txt file because i don't want and robots crawlers to get the links.

Also i want them to be accessible by the user and i don't want them to be cached by the search engines.

Also i cannot add any user authentications for various reasons.

So i am thinking about using mod-rewrite to disable search engine crawlers from crawling it while allowing all others to do it.

The logic i am trying to implement is write a condition to check if the incomming user agent is a search engine and if yes then re-direct them to 401.

The only problem is i don't know how to implement it. :(

Can somebody help me with it.

Thanks in advance.

Regards,


回答1:


I may be understanding you wrong, but I think

User-agent: *
Disallow: /

in robots.txt will do just what you want - not let any crawler in, while keeping website open for normal users.

Or do you need to specifically remove robots.txt (for what reason?) from the web server?



来源:https://stackoverflow.com/questions/6505496/how-to-replace-robots-txt-with-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!