I am using a list of known spammer ips to block spammers from my site.

This method completely blocks a visitor from the listed ip from my website. What they "see" is a 403 forbidden error.

Now, what I'm thinking is that this error will alert the spammer to the fact that I'm blocking them specifically. Because certainly I wouldn't block everyone from my site. So it must be a spam block.

This might instigate them to find a way around my block. They will start using a different ip that I haven't yet blocked. Of course I will block it, once I notice spam comming from that ip, but for a certain time, my site will be vulnerable.

So I'm wondering, if maybe a better approach would be to not block the spammers, but present them with a page that looks harmless. For example an empty page (looks like I haven't yet built my site) or even a version of my site without comment forms (looks legit, but doesn't give them anything to spam).

What is the best method – block or redirect?

  • I question the instinct to completely block visitors based on a dodgy IP. What problem are you actually trying to solve? Commented Feb 14, 2016 at 11:17
  • @AndrewLott I am blocking known spam ips from spamming my forms. The list I use gets updated at least daily and allows blocked users to apply for whitelisting. It is for Germany and does not block anyone from my country. False positives happen mostly to non-German ips (and I don't provide content for anyone outside my country anyway).
    – user52244
    Commented Feb 14, 2016 at 12:01
  • 2
    Just use fail2ban....the most hazardous threats i.e hackers won't be on those lists. Commented Feb 14, 2016 at 12:03
  • @SimonHayter Thanks, didn't know that. But does fail2ban work on a shared server? From a quick read it seems that the script will need access to parts of "my" server that is outside my user rights.
    – user52244
    Commented Feb 14, 2016 at 12:13
  • 2
    If these are actual "spammer IPs", ie. automated bots scanning for vulnerabilities and forms to spam - not real users. Then I can't really see that there would be a difference between a 403, 406, 301 or an empty 200. The only requirement is to prevent the spam request from being processed. You are never going to prevent the spam request from being made.
    – MrWhite
    Commented Feb 14, 2016 at 16:00

2 Answers 2


We need to block the Spam websites by different methods-

1)In .htaccess file as explained in this https://www.optimizesmart.com/geek-guide-removing-referrer-spam-google-analytics/ article.

2)And also create the filter in Google Analytics so that you can filter the spam traffic. Another Reference -https://moz.com/blog/how-to-stop-spam-bots-from-ruining-your-analytics-referral-data

And in my opinion try to remove them rather redirecting.Because we should avoid redirection as much as possible.Because it slows down site speed.(https://varvy.com/pagespeed/minimize-redirects.html). Because Page Speed is one of important ranking factor.(https://moz.com/blog/how-website-speed-actually-impacts-search-ranking)


Be careful, you may still be banning valid users. Tor exit nodes often get mistaken for bots, so services like CloudFlare include a CAPTCHA to verify a real person accessing the website.

You could implement something similar for your own website. If a visit comes from a questionable IP then include a CAPTCHA (or similar test) to ensure the visitor is a real person and not a bot.

If your primary concern is blocking spam comments (and not blocking the original content itself) you could just include a check against the IP before displaying the comment form. This was anybody can view your content, but visitors from the questionable IP list wouldn't even have the option to post.

  • I am not banning valid users. The list I use blocks known spam bot ips. It is updated daily and false positives can apply for whitelisting. Also, the majority of ips that are blocked lie in countries I don't provide content for anyway (e.g. China), so I'm not concerned with false positives. -- As for captchas, I want to avoid them. There are reports that comment numbers drop after introduction of captchas, forced registration or verification emails. I want to keep my forms open to all, if possible, and using this list to block spammers has reduced my spam to zero in the past three years.
    – user52244
    Commented Feb 14, 2016 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.