Checking my Google Analytics I'm getting a lot of traffic from semalt.com. I know this is a traffic spam tactic, so I want to completely block their requests and stop it from turning up in my traffic stats.
I read here http://logorrhoea.net/2014/01/how-to-block-semalt-com-referrer-traffic-using-htaccess/ that on Apache it can be done like:
# block visitors referred from semalt.com
RewriteEngine on
RewriteCond %{HTTP_REFERER} semalt\.com [NC]
RewriteRule .* - [F]
but I need it for IIS, probably via the web.config, but how to do it?
Ok, found something here: http://tusksoft.com/blog/posts/6/clean-up-your-google-analytics-and-help-stop-referer-spam-with-this-simple-rewrite-rule:
This seems to work:
<rewrite>
<rules>
<rule name="abort referer spam requests" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_REFERER}" pattern="(semalt\.com)|(buttons\-for\-website\.com)" />
</conditions>
<action type="AbortRequest" />
</rule>
<!--The rest of your rules, if you have any-->
</rules>
</rewrite>
Try this, it should work:
<rewrite>
<rules>
<rule name="RequestBlockingRule1" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_REFERER}" matchType="Pattern" pattern="*.semalt.com*"
ignoreCase="true" negate="false" />
</conditions>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
I have tested and verified this but for a referrer URL other than *.semalt.com. The key in this code, different from your code, is a wildcard at the end of the referrer pattern because the referer URL ends with a "/". You can also replace the wildcard at the end with a "/" though I think a wildcard should be better.
What follows is a sample web.config with a equivalent URL Rewrite configuration to the one you have provided.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="block semalt referer" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_REFERER}" pattern="*.semalt.com" />
</conditions>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With