Even though you may have installed Jay Allen’s MT-Blacklist to thwart comment spam, wouldn’t it be nice to deny spambots from consuming your system’s bandwidth and CPU by redirecting them to an ‘error page’ especially designed for our vermonous visitors?
Apache Wunderwerkzeug : mod_rewrite
A quick tip-toe through our archives and you’ll see that in the past we’ve given some detailed attention to the use of mod_rewrite for a variety of tasks, including:
- as a tool to redirect old, well indexed pages and/or domains to new pages;
- to make your URLs search engine friendly;
- to switch from html or shtml to php without causing link rot;
- to tell evil spambots to go to H-E-Double Hockey Sticks!
Comment spam … sucks
Like most legit webmasters, I’ve also given the topic of spam quite a bit of coverage on this blog, such as:
- dealing with comment spam;
- the dreaded Nigerian 419 Scam Spam;
- my Patented Anti Spam Email Obfuscation Tool;
- using mod_rewrite to tell spambots to go to H-E-Double Hockey Sticks!
Unix-Girl to the rescue
So just in time for a weekend project , I found a brilliant bit of mod_rewrite by Kasia Trapszo, a.k.a. Unix-Girl, that concatenates these two topics into an effective way to thwart comment spam.
On her page, Kasia details a very simple snippet that demands anyone filling out a comment form first be referred by an article on the same site. In other words, bots just can’t come in out of the blue and fill out a form without at least first pretending to have read the article.
While I believe she, is running Jay Allen’s MT-Blacklist, this form of .htaccess hackery is a good idea as it gives her publishing system and bandwidth a break by stopping this type of scum at the door.
With a little experimentation, this little code gem could also be used to protect any form on your site. Then again, this is mod_rewrite, so be careful not to shoot your foot off. Oh, and let me know if you come up with something unique based on Kasia’s kool example.