阻止所有用户无引荐者,但允许Googlebot / bingbot在同一时间(使用.htaccess)

由于一些业余的DDOS攻击我的网站,我不得不否认一些交通.htaccess工作正常。

不幸的是,它也阻止了googlebot / bingbot:

order allow, deny deny from 54. SetEnvIfNoCase Referer "^$" bad_user SetEnvIfNoCase User-Agent "^Wget" bad_user Deny from env=bad_user 

它只是阻止来自54.xxx整个stream量(只有来自它的stream量来自受感染的亚马逊云 – 我知道我可以排除亚马逊云只有30个IP范围,而不是整个54.xxx但我需要快速解决scheme)。

其余的机器人(大多数来自中国,台湾等)不使用引用,所以:

 SetEnvIfNoCase Referer "^$" bad_user 

阻止他们。

但它也有一个副作用

  1. 当有人通过书签访问我的页面,或者直接input到浏览器(例如他在名片上显示红色)时,他将不会看到我的网站。
  2. Googlebot,bingbot(以及其他不太重要的机器人)通常也不使用引荐来源。

#1是一个不便,但#2是一个真正的问题,我必须迅速解决。

我发现对我来说重要的机器人使用这些标签:

 66.249.64.119 - - [...] "GET /robots.txt HTTP/1.1" 403 534 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 66.249.64.119 - - [...] "GET /programowanie/ HTTP/1.1" 403 537 "-" "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 66.249.64.115 - - [...] "GET /3d-graphic/ HTTP/1.1" 403 535 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" 207.46.13.4 - - [...] "GET /robots.txt HTTP/1.1" 403 534 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" 207.46.13.4 - - [...] "GET / HTTP/1.1" 403 524 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" 

是否有可能在.htaccess以某种方式合并我的规则与“但如果标签包含”Googlebot“或”bingbot“,让他去”作为最重要的一个(即使他们不使用referrer)?

如果没有,也许我可以添加一些robots.txt通知谷歌/必应他们应该把引用标签(我怀疑他们会考虑到)?

我find了一些解决scheme#2

 order deny,allow deny from 54. SetEnvIfNoCase Referer "^$" bad_user SetEnvIfNoCase User-Agent "^Wget" bad_user SetEnvIfNoCase User-Agent "http://www.bing.com/bingbot.htm" good_user SetEnvIfNoCase User-Agent "http://www.google.com/bot.html" good_user Deny from env=bad_user Allow from env=good_user 

注意order deny, allow – 感谢它会这样工作:

  1. 阻止来自54.xxx所有stream量。 也阻止所有stream量,无需引荐来源。
  2. 然后,解锁包含http://www.bing.com/bingbot.htmhttp://www.google.com/bot.html的请求的stream量。

无论如何, 我会等待其他答案 ,因为我不确定是否是最佳解决scheme#2

而且我还没有设法解决#1

所以如果你想:

阻止所有用户无引荐者,但同时允许Googlebot / bingbot

你可以使用我的代码.htaccess没有deny from 54.SetEnvIfNoCase User-Agent "^Wget" bad_user行,这是特定于我的情况(ddos)。