Banning A Referrer

May 9, 2008 – 7:34 am

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

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.

If you enjoyed this post, subscribe to the Sootle RSS feed!.

Post a Comment