Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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:



share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.