#Add this to your .htaccess file
# Referral spam blocker
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} (INSERT_REFERER_HERE) [NC]
RewriteRule .* – [F]
</IfModule>
##Explanation
<IfModule mod_rewrite.c>
RewriteEngine On
...
</IfModule>
Make sure that rewriting is available, and turn it on.
RewriteCond %{HTTP_REFERER} (INSERT_WEBSITE_HERE) [NC]
Check the HTTP Referer, and if it contains the text "INSERT_WEBSITE_HERE", then do the action.
If you want to check for multiple referers, just repeat this line for each referer, and add the OR
flag ([NC,OR]
).
The flag NC
means it will ignore cases. i.e. EXAMPLE.COM
is equivalent to example.com
.
RewriteRule .* – [F]
Here we just throw everything that matched away with a 'Forbidden' status code.