Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I block Semalt on IIS

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?

like image 702
Adam Avatar asked Mar 05 '14 19:03

Adam


3 Answers

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>
like image 104
Adam Avatar answered Sep 23 '22 00:09

Adam


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.

like image 33
Nagesh Chopra Avatar answered Sep 22 '22 00:09

Nagesh Chopra


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>
like image 36
ademar Avatar answered Sep 23 '22 00:09

ademar