2014-03-05 21 views
6

检查我的Google Analytics(分析)我从semalt.com收到大量流量。 我知道这是一个流量垃圾邮件策略,所以我想完全阻止他们的请求,并阻止它在我的流量统计中出现。如何在IIS上阻止Semalt

我这里http://logorrhoea.net/2014/01/how-to-block-semalt-com-referrer-traffic-using-htaccess/阅读在Apache它可以像做:

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

,但我需要它的IIS,可能是通过在web.config,但是怎么办呢?

+0

最近,我也看到了 “semalt.semalt.com” 为参照网址。 –

回答

6

好吧,发现这里的东西:http://tusksoft.com/blog/posts/6/clean-up-your-google-analytics-and-help-stop-referer-spam-with-this-simple-rewrite-rule

这似乎工作:

<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> 
+0

感谢@Flo在我所有的网站最是烦人的social-buttons.com因此增加他们在system.webServer <规则名称=“中止引荐垃圾邮件请求” stopProcessing =“真”> <匹配的网址=“。*”/> <动作类型= “AbortRequest”/> <! - 你的规则的休息,如果您有任何 - > Langeleppel

+0

要添加到我的答案中:并非所有引荐垃圾邮件都会设置引用来源主机名,因此这些仍会在您的Google Analytics日志中弹出。 发现这个伟大的职位在这里:http://www.analyticsedge.com/2014/12/removing-referral-spam-google-analytics 摘要:它做的是检查访问者是否设置了一个有效的主机名(如:您的网站主机名或已知的主机名)。如果没有,您可以将其过滤掉。因此,不是排除所有垃圾邮件网站(并且必须维护该列表),而只包含有效的访问。检查受众群体>技术>网络>主机名以查看网站请求的主机名。 – Flo

2

下面是一个示例web.config,其中具有与您提供的URL配置相同的URL重写配置。

<?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> 
+0

我之前用完全相同的规则回答了我自己的帖子,但我仍然在Google Analytics流量统计中查找......所以出于某种原因,此规则不起作用。 – Flo

+2

我有'stopProcessing =“true”'的其他规则,所以请确保这是您的''中的第一个条目。 – Richard

3

试试这个,它应该工作:

 <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> 

我已经测试和验证这一点,但对于参照网址不是* .semalt.com等。此代码中的关键字与您的代码不同,它是引用来源模式末尾的通配符,因为引用者网址以“/”结尾。尽管我认为通配符应该更好,但也可以用“/”替换最后的通配符。