Block traffic from single referrer

The traffic from the referrer is useful for sites rank and promotion but some time wrong referrer can cause the bandwidth and ddos attacks therefore its always better to block such spam referrer. We can block the single referrer by using the following code in the .htaccess file.

The following code will disable the referrer from blocksinglereferrer.com

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} blocksinglereferrer\.com [NC]
RewriteRule .* – [F]

If you are facing the problem from too many  referrer sites then you can refer to the following code.

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} blocksinglereferrer\.com [NC,OR]
RewriteCond %{HTTP_REFERER} blocksinglereferrer1\.com
RewriteRule .* – [F]

In above code the referrer from  blocksinglereferrer.com and  blocksinglereferrer1.com disabled.

 

About Anant 384 Articles
Senior technical writer