拒绝直接访问,但允许普通的HTML [英] Deny direct access but allow regular html

查看:171
本文介绍了拒绝直接访问,但允许普通的HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有后续的的.htaccess 上传目录:

order allow,deny
deny from all

我想允许< IMG SRC =上传/ image.png/> ,但得到forbbiden错误(403)

I want to allow <img src="upload/image.png" /> but get forbbiden error (403).

我怎么能拒绝直接访问,但允许HTML包容性(普通的HTML)?

How I can deny direct access but allow html "inclusion" (regular html)?

推荐答案

您不能(可靠)。

无论是直接或视为&LT; IMG&GT; 标签,浏览器仍然发出请求 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
  • 在人们通过网页看到的图像,如果他们输入网址的地址栏的形象很可能是从他们的浏览器缓存中,它会出现在任何服务器配置你在的地方

这篇关于拒绝直接访问,但允许普通的HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆