« Snow and stress | Main | Meet Chiplet »

Winning the spam battle (for now)

This addition to my .htaccess file has really reduced the amount of referer log spam I've been receiving, and as a bonus it also cuts down on comment spam (though I'm happily free of that thanks to MT-Blacklist, the .htaccess trick eliminates the bandwidth toll they can take).

It took some trial and error to figure out how to make this play well with the Movable Type-generated content that was already in my .htaccess file, since I've never ever monkeyed with this stuff before. The trick was to put these new instructions at the top of the file, above the MT content, and then to remove the "RewriteEngine on" line from the MT section. Otherwise the two identical lines cause a server misconfiguration error page.

Yes, this kind of inelegant method of blocking spam is inefficient and not 100% effective, but I'm seeing happy little 403 'denied' errors in my 'recent visitors' page from all the spamming domains, while legitimate traffic seems to be coming through just fine.

Posted by lld at January 24, 2005 07:40 PM

Comments

sweetney says:

umm, where can one find the .access file?

i don't see in in the root directory....

January 24, 2005 10:20 PM

sweetney says:

i mean .htaccess -- d'oh!

January 24, 2005 10:23 PM

lalitree says:

Chances are your FTP program is set to not display filenames beginning with a period, you can probably change this in prefs. Oh and warning, messing with .htaccess can mess stuff up...I totally screwed it up multiple times while doing this, causing that awful white page with the error message on it. Oh and important: you have to be running Apache for this to work.

January 24, 2005 10:33 PM

sweetney says:

ahh, gotcha.

nother thing: remember once you told me how to correct the sidebar-too-short problem on my blog? umm, any chance you could run that by me again?

sorry, i know this is your blog, not your "help desk"...

January 25, 2005 09:57 AM

lalitree says:

Heh! Don't worry, I don't mind at all. The trick is to use a repeating background gif, about 1 pixel tall and exactly as many pixels wide as your content area. Mine looks like this (hard to see, it's mostly white). Then you set that in your stylesheet as the background for #container:

background-image: url(images/bg.gif);

Hope that helps!

January 25, 2005 10:19 AM

sweetney says:

yay! all fixed (i think/hope)!

thanks again for sharing your webby knowledge...i promise to not abuse your graciousness!

xo

January 26, 2005 09:27 AM

dav0r says:

you're a nerd and you like punk. sweet. i also suggest playing around with .htaccess on a non-live box so you can see what you're changing (test it out first). also google it to see configurations and tips. i run it on a fedora core box at work.

February 7, 2005 08:24 AM

lalitree says:

Heh, indeed.

Yeah, instead of being totally safe and only mucking around in .htaccess on a non-live box, I just kept a working copy and when I messed it up, I re-uploaded the good one. This happened many times initially!

February 7, 2005 02:42 PM