How can I block a user from viewing/accessing my website?
Assuming I know the IP address(es) of the user, is there a way to do with in my HTML code? Or is this a complicated server side problem?
How can I block a user from viewing/accessing my website?
Assuming I know the IP address(es) of the user, is there a way to do with in my HTML code? Or is this a complicated server side problem?
There is no way to block an IP address using simple HTML. If you can incorporate some kind of servlets (JSP or ASP) into your web pages, you could probably do it that way. However, that’s a rather convoluted and technically advanced solution.
You can also password protect your pages so that you can’t access them without the password. However, this is implemented from the server side, so it may not work for you. And of course, if the person(s) you are trying to exclude find out the password from someone else, it doesn’t work.
HTML can’t really do much in terms of protection. You can either use a simple PHP or Perl password access (many available free on the web) or use .htaccess security. If you want more detailed info, just email me.
You could even (nowhere near being secure, but hey better than nothing) use javascript that redirects anyone with a certain IP to a “you can’t come in” page. Or use javascript to password “protect” your site. This is NOT secure, but might provide just enough resistance to make them go somewhere else if they don’t know much about the web, or don’t really care.
QED,
I found some PHP code but I wasn’t sure what to do with it. When I put everything between the <?php and ?> in the header of my HTML doc, nothing happen. In fact, I was able to see the code when my page loaded!
I know know to insert Javascript, but how do I implement PHP?
Learn how to use the .htaccess file.
Should be relatively easy with SIMPLE CGI code, (which can intercept an IP address). But why bother, since the blocked user can EASILY get in using any other entry-point (an Internet coffeehouse, a library’s computer, a friend’s account, etc).
The more common solution is to only ADMIT entry to people who have an account/password for your site, not to BLOCK entry from certain IP addresses!
If you know how to use Javascript, then there is a relatively simple Javascript “gatekeeper” script that acts as a simple password system. It’s simplistic, but it can work. It means you’d have to provide any potential people you do want to use your site with the password, however, so it may not be what you want.
Let me know (here or via e-mail) if you’re interested, and I’ll dig it up for you.
First make sure your webhost supports PHP (most freebie sitesdo not). If not, the SSI you’re trying to use won’t work. There’s javascript access control scripts too. Those will work regardless of the host. Here’s a bunch of them on this page.
You might find this article interesting. I came across it a few months ago when looking for a way to redirect traffic from a competitors website to a dummy version of our web page that was chock full of disinformation.
ExperTelligence Inc. used this method to redirect its competitor Allaire to a bogus version of their site when they discovered that Allaire was downloading trial versions of their software. The bogus version of their site is identical, only it has old software downloads not the new stuff.
Q. E. D. asks the right question: what sort of control do you have on this box?
If this is a free site, you likely don’t have much, and will have to rely on Javascript.
If this is your own box or you have good access, using .htaccess is the easiest solution. Just create a file in the directory that contains the files you want to restrict called “.htaccess”.
Put in this text:
You’re done.
PHP is another good solution, but it looks like you don’t have it running there, and getting it running could turn into a science project if you only want to use it for this feature.
The suggestion above, incidentally, will only work on Unix-powered servers, but the vast majority of them are.
Some free sites do have Perl and/or PHP support, such as Spaceports.com. Both are powerful and fairly easy to learn if you have a bit of a programming background. Or, if you’re interested, I’d be happy to hash out a script for you to do whatever you wanted it to do.