Got Trolls? Give em the Boot with .htaccess
We all have experienced and come across trolls when owning a community website or blog. I had to ban a few people from my street dance website not too long ago and a friend of mine showed me this nifty trick to ban them using their IP. Hope this can come in handy!
.htaccess File
# IP Banning order allow,deny deny from IP_address_goes_here deny from IP_address_goes_here allow from all
On top of banning them, I wanted to send them off to another website. You can do so with the following:
# IP Banning redirect page
ErrorDocument 403 http://www.youtube.com/
If you know of any other ways to get rid of trolls, please share them!
Popular Posts
Author Bio
My name is Soh Tanaka and I am a Los Angeles based designer/front-end developer specializing in CSS driven web design with an emphasis on usability and search engine optimization. I also run a CSS Gallery which is updated daily with the best CSS websites from around the world. Come check it out!
You can learn more about me or
Follow me on twitter for more updates and resources!
Did You Enjoy This Post?
Subscribe via RSS or by email to get all upcoming tutorials and articles delivered straight to you.




+ Add Comment9 Peeps Have Spoken Their Minds...
One thing I do in a PHP website is (at the start):
>r;?php
if($_SERVER['REMOTE_ADDR']==”255.255.255.255″) {
}
?<r;
Admittaly the htaccess is easier, but I find that if I can use PHP to moderate users to different sections of a website, for example sometimes you want the users to see the page, but not comment, this would work fine.
For multiple IPs i would recommend:
>r;?php
$ip = $_SERVER['REMOTE_ADDR']; //This gets the IP from their REMOTE_ADDR, and converts it to the $ip
if($ip!=”Unwanted IP1″ && $ip!=”Unwanted IP2″ && $ip!=”Unwanted IP3″) {
}
?<r;
Etc. (:
How can you do it from Refferer address
ie there is a bad forum that links to us. When people click a link from their site I want to send them else where. Can this be done with just javascript as I dont have access to htaccess on my server
Problem with stubborn trolls is that they always find proxy servers to come again and again.
nice idea, but filtering by IP might block wanted users also…
maybe I´m wrong but at home I will get a new IP every day wenn starting my access point. So the IP from yesterday would be given to someone other… What will happen if this other guy want´s to visit your website?
if your troll is surfing during his time at work he might have a static IP adress. But if you block this IP, all the other employees are blocked to… There might be a good comment writer you will send to youTube ;)
What about Cookies? The troll might block them or delete them by closing his browser. But would it be an option?
sorry for my rusty english but I´m not a native speaker…
@ James
Not sure about JS, but you could do it with PHP…
<?php
$get_ref = ($_SERVER['HTTP_REFERER']);
if ($get_ref != 'http://www.badforum.com') {
}
else {
header("Location: http://www.redirectedsite.com");
exit();
}
?>
All this does is puts the referring URL into a variable and then checks it against the offending site. If it doesn’t match, we do nothing and let the page load. If it is a match, we send them to the site of your choice.
Is that any help?
Hello. That’s my first comment here. I’ve subscribed to your rss feed a while ago and I visit this blog everyday. I just love your design and I must say 90% of your posts are really interesting and usefull.
Anyway, concerning trolls bann, I might be wrong, but I think it’s an impossible task as their IP change every day. Maybe the best way is to make them log on to comment. This way you can easily recognise them and bann them if needed. Of course it takes some time to the moderator, and especially if they create new accounts again and again but I don’t see any “miracle solution” as we say in french. You just have to wait for them to give up and troll another blog.
All great points! I guess there is really no way to get to the bottom of the trolling :-(
the battles with Spammers and Trolls continues…
When a troller’s primary intent of provoking other users into an emotional response, a flag technique, requiring a moderator and three visitors to flag and delete the blog is almost a necessity. But as other commentors have said, non static IP’s make this job a little harder. Better solutions need to be created.
Sorry guys but with the way that the internet is going these days, true online identification is fading fast. With the Pirate VS Copy Right laws going on, and just hackers in general, there will ALWAYS be more than one way to hide yourself. Especially if we want to keep the internet free.
Although you can always fight fire with fire…. as long as you’re witty enough to make a troll feel bad.
Speak Your Mind...