Block web page requests from robots with empty user agent

by rajesh 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
------------------------------------------------------
971
like
0
dislike
0
mail
flag

You must LOGIN to add comments