Scanner Redirection

I have an online tool that tracks tasks and users performing tasks. As part of the process, I write $_SERVER['HTTP_USER_AGENT'] . However, from time to time I get visits from different bots and scanners. How can I gently redirect them to another place without โ€œinfringing on their feelingsโ€?

I thought that I want to build an array with the names of the bots and run every AGENT information against it, and if it is found in the array, we redirect it.

Is there a better way to do this?

+4
source share
2 answers

If this is not already done, you can get rid of most crawlers using the robots.txt file. See here. However, this is not strictly enforced. Those who continue scanning may be blocked by IP. You can do it on Linux using iptables. Example:

 iptables -A INPUT -s IP-ADDRESS -j DROP 
+6
source

Make a list with the necessary spiders and redirect using this code:

 header('HTTP/1.1 301 Moved Permanently'); header('Location: NEED_URL_HERE'); 

In fact you can use . htaccess or robots.txt (if the crawler uses it)

  User-agent: * Disallow: / 

UPD: If you use this for SEO (cloacking), you may be punished by the search engine, be careful.

+3
source

Source: https://habr.com/ru/post/1390989/


All Articles