Using htaccess Against Spam and Spammy Comments

, , ,

As many blogs that get decent traffic know, you often get a lot of spammy comments on your posts, even when you have a decent anti-spam plugin or two.  Well, there are other routes to go when you STILL get spam comments.  And I’ve found a nice one.Any good web designer knows what the htaccess file is and what it’s used for.  What a lot of people don’t realize is how powerful this file can be, when used right.

The htaccess file is a file that works properly from the root directory of your domain.  Usually it’s used to handle issues like canonicalization, but can also adjust the traffic you get in different ways.

In my case, I had found a few individuals from China that seemed to like trying to comment on my blog about luxury shoes.  Now I understand the general misunderstanding from people trying to do SEO on blogs with comments, but really – commenting on internet marketing blog entries about shoes?  That was enough to make me go ahead and take action.

So what I did is collected the IP addresses from all of these spammers (easily findable through any of my multiple log tracing tools, in addition to being blatantly visible through the blog back end comment tab).  I took these addresses and then created two lines on my htaccess file:

RewriteCond %{REMOTE_HOST} 222.79.17.112
RewriteRule ^/(.*)$ https://www.tulsamarketingonline.com/spammer.php [R=301,L]

Once these lines were entered, what it will do is take any visitors from the specified IPs and redirected them to a lovely page I made, just for them.  And no, the IP address has NOT been hidden to protect the guilty.  To make this work properly, all you need to do is make sure you put these first two lines in your htaccess file:

Options +FollowSymlinks
RewriteEngine on

After that, just change out the IP address for the one you want to redirect, and then make that page one which you want to point them to (can be another domain entirely, if that’s your choice).  Then they can spam no more!  Or cease to bug your site, with whichever way they have offended you.  Have fun with it!

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply