And an intro to the .htaccess file...

I was excited to see my traffic stats going up on my Google Analytics account. I was less excited when I realized a sizable chunk of said traffic was coming from or with a 100% bounce rate and average visit duration of 00:00. After some research, the collective counsel of the web master community seems to be that semalt is a firm with questionable motives polluting a lot of peoples site stats. So, I set out to block them.

I had never worked with .htaccess files before, but the idea here is to put a file on the Apache server running the site that can act as gatekeeper for the site (or at least that's my current understanding). One of the possible things it can do is block any traffic from a specific domain. Bingo.

Since windows won't let you create a file without name, go to your github repo directly at and add the new file there.

Call it .htaccess.

Inside it, put the following code. Modify the "" bit for the domain from which they're currently spamming you.

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

Below is a snapshot of my Google Analytics stats for after uploading the .htacess file. Interestingly, it looks like it took a couple days for it to kick in (caching?) but then started blocking them just as desired.

Big thanks to this article for helping point me in the right direction.


portrait title

About Scott

I am a software engineer from Bozeman, MT enjoying the slightly warmer climate of Colorado. I think code can change lives. I think lives are worth changing. I write code.

You can find me on Twitter, LinkedIn, , and Github.