I can't think of a way to completely block IPs from viewing a file without using htaccess.
If you are using a server-side language (such as PHP) to generate your documents, you could stop your documents from requesting scripts. It's not perfect, but it may be what you are looking for. You could do something such as the following wherever you generate your header code:
PHP Code:
$bad_ip_list = array("127.0.0.1", "1.2.3.4"); if (!in_array($_SERVER['REMOTE_ADDR'], $bad_ip_list) echo '<script type="text/javascript" src="myscript.js"></script>';
All other methods that I can think of would require htaccess. Also, no matter which method you try to use to block an IP, if the user behind that IP really wants that Javascript file, they can still use a proxy and get it.
Just out of curiosity, why do you need to block IPs from viewing Javascript?
|