
Can I selectively block people from visiting my Web site?Dave, we've got a problem. I help run a Web site and we're finding that there's one troll out there (yes, I read your article on trolls a few days ago!) who keeps showing up and posting inflammatory comments, really ruining the guest book for everyone else. Is there a way to selective block one person without just tossing the whole guestbook out? Sorry to hear about your problems, but it doesn't entirely surprise me. For all that we as a society talk about free speech and the right to disagree, it only seems to extend in one direction: "You need to listen to me and you can't shut me up." For you to be able to accomplish what you want -- a tactic I endorse, by the way, and do not see as censorship in other than the most general way -- you're going to find that the solution varies based on what kind of Web server you have running. A good first step, therefore, is to ask your Web hosting provider what kind of server they run. A good answer is Apache, because it's flexible and easily tweaked to accomplish this task. If you have something else, like Microsoft's Internet Information Server (aka "IIS"), you'll need their help setting this up, because the solution I'm offering is Apache-specific. If you are running Apache, then go into the directory that contains the guest book (or that contains the CGI script itself, for that matter) and, in a file called .htaccess, add the following: <Directory /what/ever> Order Allow,Deny Allow from all Deny from 10.1.2.3 </Directory> Switch "/what/ever" to match the directory name. That should do it. If that doesn't work, you can also drop this block into your httpd.conf file, if you're comfortable editing that file. Once it's installed, you'll want to change the 10.1.2.3 to the IP address of the offending party (look in your log files for that information). Hope this helps you solve the problem. Good luck. My thanks to Omar W. Hannet for his help with this entry. Please pop over to the Apache Web site for more details on mod_access
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.
Categorized:
CGI Scripts and Web Site Programming
(Article 3879)
Tagged: Previous: What's a troll and a zombie? Next: Can I forward selected messages from my GMail Account? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. Dave, while your solution works for a fairly large number of cases, I see at least two flaws: it blocks EVERYONE from the entered IP address, and doesn't account for "shifting" / non-permanent IP users. (Apologies, all of my alternative solutions fall back upon inspecting user-entered identification fields, which aren't consistently supported by guestbook packages...) ttfn - Mike / Pax ... Kihe Posted by: Mike C. Baker at February 11, 2005 6:17 PMI agree. Do you have a suggestion as how you could tweak Apache to include those cases? Posted by: Dave Taylor at February 12, 2005 2:56 AMYou can use cookies to track the troll and deny access to your pages. This can be a little tricky, because you don't know in advance the new IP of the troll. One solution is to seek for words only the troll uses, and atach a special cookie to identify the computer the troll is using. Implementetion in PHP is probably the easiest way to do it. Posted by: Julio Poisot at February 22, 2005 5:31 PMYou can use cookies to track the troll and deny access to your pages. This can be a little tricky, because you don't know in advance the new IP of the troll. One solution is to seek for words only the troll uses, and atach a special cookie to identify the computer the troll is using. Implementing it in PHP is probably the easiest way to do it. Posted by: Julio Poisot at February 22, 2005 5:31 PMget your cgi to look up a list of banned words! Posted by: kjteoh at May 15, 2005 7:53 AMi can not on block her Posted by: B at August 11, 2005 2:29 PMI use Typepad to blog, and I'd like to block specific users from accessing my blog. Since i"m not hosting on Apache, do you know of any way that I could block people from visiting? Thanks! Posted by: A Hsu at December 12, 2005 4:29 PMI'm afraid you can't do that with Typepad. You can block specific people from adding comments (if you know their IP addresses) but you can't block people from *reading* your site. Sorry! Posted by: Dave Taylor at December 12, 2005 4:41 PMHi Dave, My problem is slightly different. When I look through my site's log, I see that I'm getting hundreds of hits from spam addresses in my "links from external addresses" list. I'm not sure whether the point of the spam hits is just to have webmasters check out their referrers and in that way generate traffic to their website, or whether (more likely) the idea is to have their sites show up in my log, in the hopes that the log is linked to the main site, so they can increase their Google rankings. In any case, I'm getting tired of manually listing all the offending URLs in my htaccess file. My question, therefore, is: does anyone publish a list of spam URLs that webmasters can add to their htaccess files? Or, even better, is there some service such as AdBlock that tracks the spammers and that you can somehow route your htaccess files to check? Any thoughts would be most welcome! BTW, here's my current .htaccess file Order Allow,Deny Dave, Martin and Don, I'm afraid to say that at some level the spammers win this war because you'd have a prohibitively long list of domains to block and that still wouldn't work because spam tools can "spoof" or pretend to be from other domains entirely. :-( Further, open tools like guest books are just an invitation for trouble, I'm sorry to say, so unless you can change your guestbook system to leave entries as "unpublished" until you manually approve them, you're probably better off disabling the guest book entirely. Both of these answers are terrible and I greatly miss the free and open nature of the Internet as it was years ago and every entry to a guest book was a voice from the great unknown and highly anticipated. But as far as I can see, there's no going back. :-( Posted by: Dave Taylor at February 7, 2006 1:52 PM// Block IP address script- By JavaScriptKit.com (http://www.javascriptkit.com) //Enter list of banned ips, each separated with a comma: var ip = '' var handleips=bannedips.join("|") if (ip.search(handleips)!=-1){ You will need to change the 23.23 and 11.11 of course. This works great for the most part, but if they have a changing ip address you will have to block a lot more. Posted by: Faith at May 11, 2006 7:43 AM I recently Googled an old techie friend and discovered she now has a company, and she made her email address at her company's website public. So I sent her an email, and got no reply. A few days later, I found that when I tried to go to her website my browser said it didn't exist ("cannot find" etc). Before assuming the worst; i.e. that she selectively blocked me-- I was wondering, IS this what my browser would say in such a situation? Or would it instead be something like "access denied"? I just read the posting from Van Casey on 12/1/06. I have a similar issue in that a site for the Club managers Association of America (www.cmaa.org)does not open when I click on it. I notified their techies and they said I needed to relax my security on my computer. I did that but to no avail. When I called a friend, he was able to access their site. So my question is WHAT TO DO? I cannot believe that a national organization would just seleectively block someone from accessing their site. Please help. Much appreciated. Posted by: Hondo Hughes at December 5, 2006 8:32 AMcan i block a whole bunch of IPs by using the *? for example <Directory /what/ever> I have a lot to say, but ...
I do have a comment, now that you mention it!
|
Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Join the List!
Book Links
|