How to stop referral spam

Sean Doyle

Sean Doyle is an engineer from Los Angeles, California. Sean's primary focuses include Internet Security, Web Spam, and Online Marketing.

6 Responses

  1. bogdan says:

    thank you, very helpful

  2. Aaron says:

    Wanted to add the NGINX configuration too – for those of us who don’t use Apache (and thus the .htaccess file):

    # nginx configuration
    location / {
    if ($http_referer ~* “”){
    return 403;

  3. Steve Sims - Freelance Website Designer says:

    Thanks Sean – I have applied the Google Analytics fix to my website.

  4. Mathijs Segers says:

    When I add the .htaccess part everything gets blocked, not just referer

    Not sure why I’m no htaccess guru

    • Anonymous says:

      Maybe its the entry having the “OR” part of [NC, OR] will block the RewriteRule. So, remove the OR portion and leave the NC. If you have multiple entries, leave the OR statement on all of them except for the last entry before the rewrite rule.

      RewriteCond %{HTTP_REFERER} [NC,OR]
      RewriteRule .* – [F]

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.