0

I'm using the following code to block referrer spam on a site which is receiving a huge volume of spam traffic.

I'm told that it is more efficient in terms of server load to use httpd.conf, but I'm largely unfamiliar with this type of operation and haven't found much in the way of tutorials specific to the situation. Could anyone help with tutorials or resources showing similar methods of blocking referring domains?

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} spammer-one\.com [NC,OR]
RewriteCond %{HTTP_REFERER} spammer-two\.com
RewriteCond %{HTTP_REFERER} spammer-three\.com
RewriteRule .* - [F]

In addition is it worth investing the time in blocking via httpd.conf, will it significantly reduce server load compared to the htaccess code above?

toomanyairmiles
  • 121
  • 1
  • 13

2 Answers2

3

You can try SetEnvIf Referer, something in the lines of:

SetEnvIf Referer spammer-one\.com spammers
SetEnvIf Referer spammer-two\.com spammers
SetEnvIf Referer spammer-three\.com spammers

...

Order Allow,Deny
Allow from all
Deny from env=spammers

in your vhost definition/httpd.conf file.

Further reading:

http://httpd.apache.org/docs/2.0/mod/mod_setenvif.html#setenvif

http://httpd.apache.org/docs/2.0/mod/mod_access.html

NekojiruSou
  • 344
  • 1
  • 2
  • 9
0

if you want server-wide, then you can use this in your httpd.conf:

<Directory /var/www/vhosts/*/httpdocs>

SetEnvIf Referer spammer-one\.com spammers
SetEnvIf Referer spammer-two\.com spammers
SetEnvIf Referer spammer-three\.com spammers

Order Allow,Deny
Allow from all
Deny from env=spammers
</Directory>

Replace /var/www/vhosts/*/httpdocs with the correct path on your server. The wildcard "*" does work.

durian808
  • 1
  • 1