且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拒绝直接访问,但允许普通的HTML

更新时间:2023-12-03 08:41:10

您不能(可靠)。

无论是直接或视为< IMG> 标签,浏览器仍然发出请求 http://yoursite.example.com /upload/image.png ,这两个请求将基本上是相同至于服务器而言。

Whether viewed directly or as an <img> tag, the browser still makes a request to http://yoursite.example.com/upload/image.png, the two requests will basically be identical as far as the server is concerned.

现在在大多数浏览器,从请求的&LT; IMG&GT; 标记将伴随着引用站点: HTTP头,你可以使用你的Apache配置来过滤这些请求,但是:

Now in most browsers, the request from the <img> tag will be accompanied with a Referer: HTTP header which you can use in your Apache config to filter those requests, however:

  • 这不会保护你的形象,他们可以通过任何试图获取图像添加,例如在命令行:卷曲-e'http://my_referer.example.com http://yoursite.example.com/upload/image.png
  • 在人们通过网页看到的图像,如果他们输入网址的地址栏的形象很可能是从他们的浏览器缓存中,它会出现在任何服务器配置你在的地方李不管>