RewriteEngine on RewriteCond %{QUERY_STRING} (.*)http:\/\/(.*) RewriteRule ^(.+)$ - [env=badbot:true] #then Deny from env=badbot