How to block google access using htaccess

tabish8612

Power Member
Joined
Sep 13, 2009
Messages
551
Reaction score
130
Hi, Can anyone tell me how to block google access from reading /go/ folder it containing affiliate meta refresh file using htaccess file. I know how to block using robots.txt but want to know htaccess method.
 
found this on google
Code:
[FONT=Verdana]RewriteEngine on[/FONT]
RewriteCond %{HTTP_USER_AGENT} AltaVista [OR]RewriteCond %{HTTP_USER_AGENT} Googlebot [OR]RewriteCond %{HTTP_USER_AGENT} msnbot [OR]RewriteCond %{HTTP_USER_AGENT} SlurpRewriteRule ^.*$ "http\:\/\/htmlremix\.com" [R=301,L]
Code:
www.htmlremix.com/seo/block-google-and-bots-using-htaccess-and-robots-txt
 
Put the code in a .htaccess file and add it to the go folder.

RewriteEngine On RewriteCond %{HTTP_USER_AGENT} (googlebot|bingbot|Baiduspider) [NC] RewriteRule .* - [R=403,L]
 
if u want to block google only, put only googlebot here ^^
 
Wow too many copy pasters on the block who doesn't have a clue.

OP, following code should block the google from accessing the /go/ folder. It'll show

Code:
# block google

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT}   ^googlebot
RewriteRule ^/go/ - [F,L]

Note: You should place the .htaccess in the parent directory not in the /go/ directory.

HTH
 
SmartMan: Do I need to paste this code below </IfModule>?
 
SmartMan: Do I need to paste this code below </IfModule>?

If there's already a rule mentioned within the </IfModule> , you can put the code inside it If not, you can paste the following code.

Code:
<IfModule mod_rewrite.c>


# block google


RewriteEngine On


RewriteCond %{HTTP_USER_AGENT}   ^googlebot
RewriteRule ^/go/ - [F,L]

</IfModule>
 
You mentioned put it on the main directory. If a domain was hosted from that go folder, would you need to put an additional .htaccess rule in /go to prevent further indexing?
 
You mentioned put it on the main directory. If a domain was hosted from that go folder, would you need to put an additional .htaccess rule in /go to prevent further indexing?

There's only 2 possibilities to host a domain on that folder.

1. If you add the domain as an add-on domain where the cPanel will create it for you.

2. If you setup a custom sub-domain on the same directory.

If that's the case, It's better to have a separate .htaccess within that folder with the following code.

Code:
<IfModule mod_rewrite.c>

# block google

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT}   ^googlebot
RewriteRule .* - [F,L]

</IfModule>
 
smartman: when it comes to htaccess file I have not much experience. I have addon domain and this code is written:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Can you tell where to put code? thanks
 
smartman: when it comes to htaccess file I have not much experience. I have addon domain and this code is written:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Can you tell where to put code? thanks

Edit the .htaccess & Replace it with the following code.

Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>


# block google


RewriteEngine On


RewriteCond %{HTTP_USER_AGENT}   ^googlebot
RewriteRule .* - [F]


RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


# END WordPress
 
Edit the .htaccess & Replace it with the following code.

Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>


# block google


RewriteEngine On


RewriteCond %{HTTP_USER_AGENT}   ^googlebot
RewriteRule .* - [F]


RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


# END WordPress


Can someone tell me how to block someone referring to my website(suppose its somewebsite.com) by using a form button with the following link google.com/search?&sourceid=navclient&btnI=I&q=somewebsite+website . How do I block this referral ?
 
Back
Top