Apache

How to block all user agents (crawlers, bots) using .htaccess

Published

1 min read

The below will serve a 403 Forbidden if any request is from any of the stated user-agent strings.

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|Baiduspider|archive.org|binlar|casper|checkpriv|choppy|clshttp|cmsworld|diavol|dotbot|extract|feedfinder|flicky|g00g1e|harvest|heritrix|httrack|kmccrew|loader|mi
ner|nikto|nutch|planetwork|postrank|purebot|pycurl|python|seekerspider|siclab|skygrid|sqlmap|sucker|turnit|vikspider|winhttp|xxxyy|youda|zmeu|zune) [NC]
RewriteRule .* - [R=403,L]

How to test it using browser Chrome

  1. Open Network tab
  2. Select User Agent - Google Bot screenshot-at-16-56-57.png

Are we a good fit? Let's discuss.

Tell us about your store and what you want to get done. If we're a fit, you get a clear next step. If not, we'll tell you.

  • Reply within one business day
  • Fixed estimate before we start
  • No commitment