Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将JavaScript包含限制为特定IP地址?_Javascript_.htaccess_Code Access Security - Fatal编程技术网

将JavaScript包含限制为特定IP地址?

将JavaScript包含限制为特定IP地址?,javascript,.htaccess,code-access-security,Javascript,.htaccess,Code Access Security,我希望得到你的反馈 我在calls-js.com网站上的HTML标题包含以下内容: <html> <head> <script src="http://www.hosts-js.com/some.js"></script> </head> </html> 如您所见,calls-js.com正在从hosts-js.com调用some.js 我想限制谁可以使用hosts-js.com上的IP白名单调用/查看some.js 这意

我希望得到你的反馈

我在calls-js.com网站上的HTML标题包含以下内容:

<html>
<head>
<script src="http://www.hosts-js.com/some.js"></script>
</head>
</html>
如您所见,calls-js.com正在从hosts-js.com调用some.js

我想限制谁可以使用hosts-js.com上的IP白名单调用/查看some.js

这意味着,如果用户1.1.1.1被白化,而2.2.2.2未被白化,则只有1.1.1.1能够体验到some.js所做的一切

我正在考虑编写一个PHP脚本,自动更新hosts-js.com上的.htaccess文件,以包含允许的IP地址

<Files some.js>
    Order deny,allow
    Deny from all
    Allow from 1.1.1.1, some-other-ip, another-ip
</Files>

这是最简单的方法吗,或者你能想出另一种方法吗?

你可以编写一个php/cgi/任何脚本,根据数据库查找/算法/任何内容发送文件,并对主机js进行重写,将*.js转换为myscript?file=$1

F.e。你还可以通过服务器端脚本生成js代码,并让该脚本检查客户端的IP地址在它这么做之前。很有趣。你是说像这样的事?1.浏览器请求some.js。2.服务器将请求重写为check.php。3.php查看数据库,发现IP被列入白名单,并同意可以查看JS。4.相关的JS被推送到浏览器中。如果我的理解是正确的,那么4是如何实现的?感谢脚本语言的使用。在PHP中,使用readfile plus标头设置正确的内容类型