Block web page requests from robots with empty user agent
by rajesh[ Edit ] 2012-11-29 11:38:13
To block any request to the server from an empty user agent, use the below code in .htaccess file
RewriteEngine On
RewriteBase /
SetEnvIfNoCase User-Agent ^$ bad_bot
Deny from env=bad_bot
This will give a 403 response to the spammer who try to access the site with out any valid user agent.
The response will be like
------------------------------------------------------
HTTP request sent, awaiting response... 403 Forbidden
------------------------------------------------------