How to Block Google and bots using htaccess and robots.txt

How to Block Google and bots using htaccess and robots.txt

Block Google

 

You need to have mod_rewrite enabled. Placed it in .htaccess in that folder. If placed elsewhere (e.g. parent folder) then RewriteRule pattern need to be slightly modified to include that folder name).

 

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|Baiduspider) [NC]
RewriteRule .* - [R=403,L]

Example Robots.txt Format

User-agent: *

Disallow: /subdir1/

Disallow: /subdir2/

Disallow: /subdir3/
This will block all search bots in directories

Like
Like Love Haha Wow Sad Angry