b2evolution b2evolution

  • Sign in
  • Sign up
  • About
  • Downloads
  • Hosting
  • Docs
  • Support
  • Sign in
  • Sign up
  • Manuals Home
  • Latest Updates
 
  1. b2evolution CMS User Manual
  2. Operations Reference
  3. Fighting Spam
  4. Fighting SPAM with .htaccess

Fighting SPAM with .htaccess

Keeping the spammers at bay with a hardened .htaccess should be your first line of defense with any web site.

So let’s get started!

Restricting Where Comments Originate From

Everyone likes comments, but no-one wants comment spam. The simple snippet below will restrict access to the page that is responsible for submitting comments unless the submission originates from your web site:


RewriteCond %{HTTP_REFERER} !^http://www.yourdomain.com/.*$ [NC]
RewriteCond %{REQUEST_URI} ^.*comment_post\.php$
RewriteRule .* - [F]

Limiting Common Referrer Spam

Not all domains are created equally. Some domains just seem to have more referrer spammers than others. The next snippet blocks some top level domains (TLDs) from being a referrer and points them right back to where they came from.


RewriteCond %{HTTP_REFERER} \.kr [NC,OR]
RewriteCond %{HTTP_REFERER} \.by [NC,OR]
RewriteCond %{HTTP_REFERER} \.su [NC,OR]
RewriteCond %{HTTP_REFERER} \.to [NC,OR]
RewriteCond %{HTTP_REFERER} \.ru [NC,OR]
RewriteCond %{HTTP_REFERER} \.us [NC,OR]
RewriteCond %{HTTP_REFERER} \.tf [NC,OR]
RewriteCond %{HTTP_REFERER} \.info [NC]
RewriteRule ^(.*) %{HTTP_REFERER} [R=301,L]

These rules would block sites like: http://www.iamaspammer.to, http://i.will.spam.you.ru, http://buylandinflorida.info etc.

This is a work in progress, stay tuned for more or check in here: http://forums.b2evolution.net/topic-3764

Created by fatimahnasra • Last edit by fplanque on 2020-06-09 00:24 • •

No feedback yet

On this page

  • Restricting Where Comments Originate From
  • Limiting Common Referrer Spam

Search the Manual

Content Hierarchy

  • b2evolution CMS User Manual
  • User's Guide
  • Installation / Upgrade
  • Front-office Reference
  • Back-office Reference
  • Developer Reference
  • Operations Reference
    • Security
    • Fighting Spam
      • Introduction to Fighting Spam (AntiSpam)
      • Recognizing a crawler attack
      • My blog is slow because it's hammered with comment SPAM! How do I recover?
      • Creating an Antispam Plugin
      • Confusing SPAMbots by changing your file structure
      • How to control referrer spam hits from search engines
      • Antispam Tips
      • Fighting SPAM with .htaccess
      • Delete User Data
      • Places of automatic blocks
      • I can't post "spam" to my own site!
      • Blocking actions
    • Performance
    • Using Multiple Domains
    • Intranet setup
    • LDAP Integration
    • Troubleshooting
    • Bundled Plugins
  • Advanced Topics
  • Glossary
  • Archives
Social CMS

This online manual is powered by b2evolution CMS – A complete engine for your website.

About b2evolution

  • What is it?
  • Features
  • Getting Started
  • Screenshots
  • Online demo
  • Testimonials
  • Design philosophy
  • Free & open source
  • Terms of service

Downloads

  • Latest releases
  • Skins
  • Plugins
  • Language packs

About us

  • About us
  • Contact

Webhosting Guide

  • Web hosting blog
  • Best web hosting
  • Cheap web hosting
  • Green web hosting
  • Hosting with SSH
  • VPS hosting
  • Dedicated servers
  • Reseller hosting
  • Int'l: UK / France

Docs & Support

  • Online manual
  • Forums
  • Hire a pro !

Other

  • Adsense
  • Press room
  • Privacy policy

Stay in touch

  • GitHub
  • Twitter
  • Facebook
  • LinkedIn
  • News blog
  • RSS feed
  • Atom feed

Founded & Maintained by François Planque