Mobile app version of vmapp.org
Login or Join
Reiling115

: Banning IPs through my htaccess doesn't work. Why? The story is incredibly long. Long story short, someone is using amazonaws IPs for a bot that's clicking on my Adsense ads. I'm trying to

@Reiling115

Posted in: #Htaccess

The story is incredibly long. Long story short, someone is using amazonaws IPs for a bot that's clicking on my Adsense ads. I'm trying to ban all amazonaws IPs, but it doesn't work. The bigger problem is that I can't ban any ip.

I tried this:



RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} ^http://.*amazonaws.com [OR]
RewriteCond %{REMOTE_HOST} ^.*.compute-1.amazonaws.com$ [NC,OR]
RewriteCond %{REMOTE_ADDR} ^xx.xx.xxx.xxx [OR]
RewriteRule ^(.*)$ - [F]



xx.xx.xxx.xxx is an IP that I have access to and with which I can test if the htaccess works. Otherwise, I tried banning myself to see if it works. Doesn't.

I also tried the classic code:


# BAN USER BY IP

order allow,deny
allow from all
deny from 1.2.3.4



Didn't work either.

What am I doing wrong and why can't I ban any ip, let alone the amazonaws ones?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Reiling115

2 Comments

Sorted by latest first Latest Oldest Best

 

@Murphy175

Report it to Google. This is fraud and they investigate it (and will refund costs/void invalid clicks).

Depending on the bot (user agent) it might be easier to ban that user agent. By AdSense I'm guessing you mean display ads as it's unlikely you'd be concerned about bots that were earning you more money. Banning a user agent won't deter anyone with any skill, but neither will banning an IP address.

Conversely, you could exclude the IP address from seeing ads in AdWords Ads (campaign settings).

10% popularity Vote Up Vote Down


 

@Becky754

Check your /etc/apache2/apache2.conf or /etc/apache2/httpd.conf, or if you have multi-hosting, /etc/apache2/sites-available/mydomain.com.conf for the presence of AllowOverride All.

Next try it this way:

RewriteEngine On
RewriteCond %{HTTP_REFERER} ^.*amazonaws.com$ [NC,OR]
RewriteCond %{REMOTE_HOST} ^.*compute-1.amazonaws.com$ [NC,OR]
RewriteCond %{REMOTE_ADDR} ^12.148.196.(12[8-9]|1[3-9][0-9]|2[0-4][0-9]|25[0-5])$ [OR]
RewriteRule .* - [F,L]


These are examples created from my own .htaccess file. The IP address range in the example is an amazonaws.com IP address range, but may not be the IP address range that you need. You notice I removed the RewriteBase. It is not necessary unless you need it for another reason.

You may also want to break these up into separate Cond/Rule sets to make things easier. If there is even one error using [OR], then the whole set fails. If you separate into three separate sets, the only the one that fails - fails.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme