Forum Moderators: phranque

Message Too Old, No Replies

Please check my htaccess code to stop bots based on UA.

         

born2run

11:26 pm on Sep 28, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So I've added this code to the end of my htaccess:

===========

SetEnvIfNoCase User-Agent "SemrushBot" bad_bot
SetEnvIfNoCase User-Agent "AhrefsBot" bad_bot
SetEnvIfNoCase User-Agent "YandexBot" bad_bot
SetEnvIfNoCase User-Agent "CCBot" bad_bot
SetEnvIfNoCase User-Agent "WOW64" bad_bot

<Limit GET POST HEAD>
Order Allow,Deny
Allow from all
Deny from env=bad_bot
</Limit>

======================

Is this code above correct? Or there's a better way? Thanks!

keyplyr

12:19 am on Sep 29, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why you'd want to block bots that bring you Adsense advertisers is beyond my understanding.


[webmasterworld.com...]

lucy24

12:46 am on Sep 29, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What, if anything, is the intended significance of the <Limit> envelope?

born2run

12:52 am on Sep 29, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks, which one of the above bring adsense advertisers? I did google search on each of these bots.. perhaps I need to remove the following:

SetEnvIfNoCase User-Agent "CCBot" bad_bot
SetEnvIfNoCase User-Agent "WOW64" bad_bot

I've already removed WOW64 as it is too generic... I'll check again on CCBot..

born2run

12:54 am on Sep 29, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ok thanks keyplyr I have only this code now, I've removed the rest as shown above:

SetEnvIfNoCase User-Agent "AhrefsBot" bad_bot
SetEnvIfNoCase User-Agent "YandexBot" bad_bot

keyplyr

1:19 am on Sep 29, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



born2run,

1.) What makes you think blocking the world's 3rd largest search engine, Yandex, is a good idea?

2.) Ahrefs is used by marketers (those people who advertise on Adsense & other ad services.) Why would you block them? You publish Adsense.

The bigger issue is that you are blocking without any understanding of what you are doing. You don't know how to code it, you don't know anything about the UAs you are blocking, and you don't understand the impact it could have on your website.

Don't block UAs or IPs until you understand these things. If at some point you feel you have a comprehensive understanding of what you are doing, be prepared for constant maintenance of these blocking rules. This is not something you do once then forget about. UAs change, IPs change, companies change. The internet *is* change.

born2run

3:10 am on Sep 29, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ok as always you are right. Ok I'll remove the code for now.. thanks!

keyplyr

9:26 am on Sep 29, 2017 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You're moving in the right direction by wanting to be specific about blocking, instead of using a generic file at Cloudfare (which is too general and blocks too many visitors and beneficial bots IMO)

But you need to do a lot of reading and asking questions so you can understand all this. When you block anything/anyone, there is always a price to pay. You need to understand what that is and how it affects your website.