I got a hit from a crawler with a user-agent called DV CRAWLER
which is an abvious a spam-bot. I tried to block it in both .htacess and nginx configuration as I'm running nginx as a reverse proxy in front of apache.
Here is the code I used for .htaccess
RewriteCond %{HTTP_USER_AGENT} ^.*(Baiduspider|DV CRAWLER).*$ [NC]
RewriteRule .* - [F,L]
Seems that the spacing in the name of the user agent has broke the code. I discovered that it only works with user agents that has no spaces. Same scenario with nginx, it doesn't accept spacing in the name of user agent and returns error.
Nginx code:
if ($http_user_agent ~ (Baiduspider|DV CRAWLER) ) {
return 403;
}
So, what is the alternative for this? I don't want these spam bots to crawl my website. Any answer would be greatly appreciated.
%20
in this context would try to match the literal string "%20".