How to block referrer traffic using .htaccess

The short version

Block from your site by adding these lines to your .htaccess file

# block visitors referred from
RewriteEngine on
RewriteCond %{HTTP_REFERER} semalt\.com [NC]
RewriteRule .* - [F]

The long version

This is going to a massively geeky post compared to my usual rubbish but I hope at least a few people will find it useful.

A few days ago, I was checking the site stats on and noticed that a domain – – kept popping up with a url that contained ‘competitors_review.php’. I took a look at the link (I’m deliberately not posting that up the link since I think that’s what these traffic spammers want) and there’s very little information: just a sign-up form. I did a bit of digging around and judging by what I’ve seen on other blogs and on Twitter, the general consensus is that are best avoided and there’s a whole load of suspicion about why they’re trying to harvest information about people by getting them to sign up to whatever service it is they’re offering with their Facebook accounts. It’s kind of clever – playing on people’s curiosity and making it look like a ‘competitor’ site is gleaning information from your site – but it stinks. If anyone from wants to put the counter argument, I’m all ears.

Update 21 Jan 2014: found a couple of other blogs with a bit more info about See WTF is and What is the website about?

Anyway, onto the practical bit. I’ve now blocked from appearing in my site stats by adding these lines of code at the end of my .htaccess file. Disclaimers: the .htaccess directives below are based on information in Media Temple’s knowledge base article: How to block a specific IP address from accessing your website. This works for my particular WordPress blog and its .htaccess file. I put them at the very end of my own particular .htaccess file. YMMV, and I provide no warranty as to what this might do to your own site. If you don’t know what your .htaccess file is or how to change it, I’d suggest you find some other way to block

# block visitors referred from
RewriteEngine on
RewriteCond %{HTTP_REFERER} semalt\.com [NC]
RewriteRule .* - [F]

172 comments on “How to block referrer traffic using .htaccess”

  1. DerrickE says:

    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^http://.*semalt\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*kambasoft\.com [NC,OR]
    RewriteCond %{HTTP_REFERER} ^http://.*savetubevideo\.com [NC]
    RewriteRule (.*) [R=301,L]

    This is what Alvi and Gina were trying to do, with some improvements.
    This blocks the semalt urls (including subdomains)
    and redirects their bots back to them. If you simply want to deny access, change 301 with 403

    Just place this at the very top of your .htaccess file.
    If you want to block/redirect any other domains, just add them in the following format:
    RewriteCond %{HTTP_REFERER} ^http://.*domain\.com [NC,OR]

  2. […] I haven’t tried this one yet and I typically don’t get deep into code (over my head mostly) for my clients but you can give the advanced method to block a try too.  It has to do with adding a snipit of code to your .htaccess file and I have attached some links for that too; Block Semalt or Block Referrer Traffic. […]

  3. Greg Kristan says:

    I just added this line of code to my HT Access file. I am really excited to see if this stops the amount of useless traffic and spam I keep getting to my site

    Thanks for the help!


  4. Brad says:


    I am dealing with the same crap with a bunch of my clients’s sites. I have just been blocking them by excluding the traffic in the admin section of my site. I just wrote a quick post on it on my site here

    Let me know if you think that way works just the same.


  5. ccm says:

    Thanks for the tip on blocking semalt and other analytics “spammers”. As a small-time webmaster, this info saved my bacon with an annoyed client.

  6. Al says:

    I was investigating this problem and the first hit on seamalt crawlers is this page:

    Doesn’t seem malicious and they offer an opt out.

    • marek says:

      You sound like someone working for semalt or have no idea what you talking about. First off, if it was a legit crawler it would have identified itself as such and obey robot txt file. Instead this cockroach of the internet is pretending to be a user screwing up webmaster’s stats and eating precious bandwidth. Moreover, this cockroach of the internet once blocked tries to sneak back using questionable methods. On top of it they send useless fake traffic. Let me tell you this, a legit crawler DOESN’T behave like this. A useless cockroach or scumbag like semalt DOES. Thanks to the contributors to this post I and I hope other webmasters were able to get rid of this cockroach wasting people’s time.

    • Greg says:

      Doesnt work, I opted out months ago and still get spammed by them. Theres a post on another blog where people have had the same problem with this rubbish continuing.

      Hope this htaccess mod works!!

  7. jack says:

    I installed this code on 11 different websites. Semalt is still getting through.

  8. […] their site’s htaccess /webconfig files if they have […]

Leave a comment