Author image
Senior Mind

Using mod rewrite to stop attempted spam on the emailpage module

We inherited a site that was running a very old (probably un patched) version of Drupal 4.6. The site was getting a massive number of hits to the URL /emailpage - at least 20 a minute, even when there was no other traffic on the site.

This looked suspiciously like a mail header injection problem. Even though the server was not currently sending out any spam we figured that at some point in the past the emailpage module was running un secure, and the site got itself onto someone's spambot list :(.

So what to do. Well first things first, we rapidly upgraded the site to a shiny new Drupal 5 installation. This 'solved' one problem in that there is no emailpage module available yet so no worries about potential spam! But the site is still on the spambot lists, and we are still getting a bunch of hits to the URL /emailpage ... not only does this clutter the logs, but it is also making the server work much harder than it needs to, for each one of those page not found errors in the watchdog Drupal has to be bootstrapped and DB queries made.

To get round the problem we wrote a simple little modrewrite rule and placed it in the .htaccess file - you can see the rule below

# Rewrite the nasty hits to the emailpage 
RewriteRule ^emailpage / [F]