I
I
Ibishka2020-05-08 01:29:03
htaccess
Ibishka, 2020-05-08 01:29:03

How to close access to the robots.txt file to non-robots?

How to close access to the robots.txt file to non-robots?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
felony13twelve, 2020-05-08
@felony13twelve

<Files robots.txt>
deny from all
</Files>

W
wisgest, 2020-05-08
@wisgest

There are quite a few robots that take robots.txt into account, and new ones are appearing. How do you at least let them know that they are denied access? You just should not put links to secret sections of the site in robots.txt - if there are no incoming links to them, then decent robots will not climb there even without robots.txt.
You can try by User-Agent, but it's easy to fake it:

# User-Agent большинства роботов содержит токен, заканчивающийся на "bot"
RewriteCond %{HTTP_USER_AGENT} !bot\b [NC]
# Дополнительно перечисляем характерные участки User-Agent, не удовлетворяющих предыдущему условию
# (список можно продолжить...)
RewriteCond %{HTTP_USER_AGENT} !\b(yahoo\.com|baidu\.com)/
## или так
#RewriteCond %{HTTP_USER_AGENT} !\b(Slurp|Baiduspider)\b
RewriteRule ^robots\.txt$ - [R=404]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question