As suggested in comments create a file robots.txt
under DOCUMENT_ROOT with following content:
User-Agent: googlebot
Disallow: /
Allow: /allowed-folder/
If you really want to handle this via mod_rewrite then enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} Googlebot [NC]
RewriteCond %{REQUEST_URI} !^/allowed-folder/ [NC]
RewriteRule ^ - [F,L]