SetEnvIf and Deny from to block bad referrers

Posted on 2005-05-03
Last Modified: 2008-03-17
My web site is getting referrer spammed and I hate it.  So I put this in my .htaccess:

SetEnvIf Referrer ^http://(www\.)?(closeouts-central|aaacloseoutsnetwork|rstrading|poolsharp|algebra-test)\.com keep_out
Deny from env=keep_out

Which had no result.  I continued to notice spam referrals from these domains.  What's the right way to do this?
Question by:arantius
    LVL 27

    Accepted Solution

    referer = only one 'r' here. This is a spelling mistake in the rfc

    SetEnvIf Referer ^http://(www\.)?(closeouts-central|aaacloseoutsnetwork|rstrading|poolsharp|algebra-test)\.com keep_out
    Deny from env=keep_out

    But you'll still find those log entries, because now a 403 forbidden is logged. To avoild logging, add env=!keep_out to your logging command in httpd.conf:

    CustomLog logs/access_log combined env=!keep_out
    (onl log requests if env keep_out is not present)
    LVL 18

    Author Comment

    This is a little hard to test, but I will try that and get back to you.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
    Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now