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 ^/(.*)$ http://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!
Related Posts
Posted: May 9th, 2010 under Blog, Email Marketing, Security, Web Design.
Comments: 4
Comments
Comment from admin
Time: May 19, 2010, 9:36 am
And the irony of this particular post getting hit by spammers is rich. Thank you, spammers! It helps me find all the IPs missing from my htaccess file.
Comment from admin
Time: May 21, 2010, 12:25 am
Alas, I found one bug with my code. I was wondering why my wonderful page wasn’t getting hits. It’s because I had put “\.php$” instead of “^/(.*)$”, so it was redirecting from the new page back to itself infinitely. It’s now fixed.
Comment from honey
Time: July 25, 2010, 11:28 pm
Good features your secrets are fantastic and good
Comment from Jeremy Goheen
Time: January 25, 2011, 12:18 pm
Was just browsing you website and see you have good design qualities to help me learn more about Graphic Design. I am taking a couse online with Loyalist College. So keep up the good work…


Write a comment