RewriteEngine On
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.*yourdomain.com.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) http://%{REMOTE_ADDR}/$ [R=301,L]

I'm aware that the following code Denys Access to No Referrer Requests.

However I'm using a multiste installation and I would like to know.

How can I modify it so the code above to work with WP multiste and mapped domains?


You could hook intop pre_comment_on_post:

add_action( 'pre_comment_on_post', function(){
    if ( empty ( $_SERVER['HTTP_REFERER'] ) )

But … be aware, not all requests without an referer are actually spam posts. Some firewalls and proxies strip this field. And most automated spam comes with a Referer field filled with the name of the spammed domain. So you will get many false positives.

|improve this answer|||||
  • it's better than touching .htaccess and it's true you get a lot of positives with this method of spam detecting – JMau Jul 5 '13 at 0:41
  • Is there any sold/better way to approach this for Multiste to reduce the false positives? – Oudin Jul 8 '13 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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