Forum Moderators: mack
I don't have the pleasure of being able to create my own .htacess file according to my site host, so I have to do it in JavaScript or html.
I found this code (below) and I like it but for one thing. It blocks ALL ip's including mine.
Please help me fix it so that it will block only the one IP address that I need it too.
************Here is the code I have now(I LIKE how it redirects but it blocks everyone)*********
<!--#if expr="${REMOTE_ADDR} = /^XX.XX.XXX.XXX/"-->
<script language="javascript">
alert("The website you are trying to view has been removed!");if (confirm)
{location.href="http://www.google.com" } else {{location.href="http://www.getalife.com" }}
</script>
<!--#endif-->
*******************************************
This code below I could not get to work for me at all
****************************************
<script language="javascript">
var ip = <!--#echo var="REMOTE_ADDR"-->
if (ip <='XX.XXX.XXX.XX') {
alert("STOP! You are not authorized to access this page!");
alert("Do not attempt to return, or your computer will begin a self-destruct sequence!");
if (confirm("Please leave now Or you will be forceably removed!"))
{location.href="http://www.google.com" } else { ("OK your choice, doesn't matter to me! SeeYa!"); {location.href="http://www.getalife.com" }} }
</script>
Thanks in advance
Welcome to Webmasterworld!
You don't have the access to an .htaccess file, but are you given a scripting language you can work with. If so, it would be fairly easy to redirect them to a "not authorized" page and the rest of your site users get to see your content. Scripting support will vary. Check to see if they have PHP, PERL, ASP, JSP, or CFM capability. Any of them will do.
Good luck!
-- Zak
Do you know of a javascript that will do that without redirecting everyone like what I am using now?
Here is what I have now and it redirects everyone
<!--#if expr="${REMOTE_ADDR} = /^XX.XX.XXX.XXX/"-->
<script language="javascript">
alert("The website you are trying to view has been removed!");if (confirm)
{location.href="http://www.google.com" } else {{location.href="http://www.getalife.com" }}
</script>
<!--#endif-->
Many Thanks
I'd suggest switching hosts. One that would argue the superiority of Javascript over a Server-Side (Behind the scenes) Scripting language is daft. What's to stop the intruder from simply unchecking the "enable Javascript" in his browser? If it were on the server-side, it could not be disabled. It is ignorant to think that a javascript could stop somone from visiting a site if they wanted. For that matter, if they REALLY wanted in, although they would have to go through some trouble, even a server-side script wouldn't stop them. The point is that Javascript is easily disabled and a scripting language cannot be "gotten around". Any host that told me I'd be "better off using Javascript" for this particular application, I'd high-tail away from. But that's just my personal opinion. :0)
-- Zak