我正在尝试在客户端和服务器端阻止推荐人垃圾邮件:
客户端:
<script type='text/javascript'>
var unforgivable = ["darodar.com", "econom.co", "ilovevitaly.co"];
var re = new RegExp(unforgivable.join("|"), "i");
if (document.referrer.match(re))
window.location = "http://google.com/";
</script>
服务器站点,通过 servlet 过滤器:
static String[] unforgivable = new String[]{"darodar.com", "econom.co", "lovevitaly"};
for (String badUrl: unforgivable)
if(requestURI.contains(badUrl)) {
res.setContentType("text/html");
PrintWriter pw=res.getWriter();
response.sendRedirect("http://www.google.com");
pw.close();
}
然而,当我查看我的谷歌分析时,我不断得到 ilovevitaly.co 和 darodar 推荐人。有什么线索吗?