# Way 1. mod_rewrite way.
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} ^Mozilla\/5.0.*Googlebot [NC]
RewriteRule ^ - [F]
# Way 2. SetEnvIf way.
SetEnvIfNoCase user-agent "^Mozilla\/5.0.*Googlebot" ua-var=1
<Directory /path/to/documentroot>
# Add/Remove options. Up to you to decide what to allow.
Options SymLinksIfOwnerMatch Indexes
# Add override options if you want to allow htaccess.
AllowOverride None
# The following lines determines access to the site.
Order allow,deny
Allow from all
Deny from ua-var
</Directory>