Banning A Referrer

by Darren McLaughlin

May 9, 2008 – 7:34 am

If you’re tired of getting spammed from a single referrer, rejoice. There’s no need to take it, and implementing a ban for a referrer is as easy as pie. That is, if you’re using mod_rewrite.

If you are using mod_rewrite, then you simply add a rule to your .htaccess files as follows:

RewriteCond %{HTTP_REFERER} offender\.com [NC]
RewriteRule .* - [F]

Merely replace the “offender” with the actual domain name of the offending website. Any referrer from that website will now get a 403 Forbiden message.

Problem solved.

Tags: , ,

Sorry, comments for this entry are closed at this time.