Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have downloaded my access log file from my cPanel and found I have a bot I would like to stop. In the access log, there User-Agent string reads the following; - - [08/May/2014:23:29:52 -0500] "GET / HTTP/1.0" 301 - "-" "-" - - [08/May/2014:23:29:56 -0500] "GET / HTTP/1.0" 200 29019 "-" "-"

What is the proper format in my .htaccess file to block this bot only?

share|improve this question
There is no user agent string in there – John Conde May 9 '14 at 19:20
Those are complete access log entries. The User-Agent is just the last part ie. "-" (a single hyphen, which probably represents an empty user agent string.) – w3dk May 9 '14 at 20:20

To block all "blank" User-Agents or User-Agents consisting of a hyphen, you could use the following in your .htaccess

RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteRule ^ - [F]
share|improve this answer
can anyone explain how it works? ^-?$ what does it mean? – Jim Thio Apr 25 '15 at 8:50
The first line indicates a conditional rewrite, in this case if the user-agent matches the regular expression which is blank with an optional - character. If the condition statement is true, then the rewrite rule on the next line is triggered. In this case the rewrite rule is to not rewrite the URL at all, but to return an HTTP forbidden code (403). – nathangiesbrecht Apr 25 '15 at 13:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.