.htaccess to allow google ads (the indexing bot) [or limit user-agents via .htaccess]

Sometimes there is a need to only allow limit access to a site using a .htaccess file.
If you still wish to be able to serve Google adsense on this page then the following example is good for this (yes the allow line should be changed to suit your needs)

# Google_ads agents
BrowserMatchNoCase Mediapartners-Google good_pass
BrowserMatchNoCase Adsbot-Google good_pass
<LIMIT GET POST>
order deny,allow
deny from all
allow from 123.456.789
#Google ads
allow from env=good_pass
</LIMIT>