我在我的网站上有一个用于缓存大型flash电影的文件夹,我想阻止其他人将它们嵌入到他们的网站中;我想尝试只使用web.config文件来做到这一点。如何做到这一点呢?
我第一次尝试一个规则(它不起作用):
以下规则应该阻止对缓存文件夹'CurrentCache‘- http://myurl.com/ContentCache/中的.swf文件的公共访问(和嵌入),并给出一个替换的电影'NoEmbedFromCacheSWF.swf’。
<rule name="Prevent SWF hotlinking" enabled="true">
<match url="^(ContentCache)(.swf)$" ignoreCase="true" />
<conditions>
<add input="{HTTP_REFERER}" pattern="^http://(.*\.)?myurl\.com/.*$" negate="true" />
</conditions>
<action type="Rewrite" url="/Content/Flash/NoEmbedFromCacheSWF.swf" />
</rule>提前感谢!
注意:我想我把<match url="A swf inside /ContentCache/" ignoreCase="true" />行中的正则表达式弄错了,你知道应该怎么做吗?
发布于 2012-04-05 23:47:51
您可以为此构建一个HttpModule。有一篇博客文章准确地描述了你想要做的事情,我认为:
HttpModule to block external referrers in ASP.NET
编辑:,当然,我在这里只是在违背web.config的规则。你必须使用一个外部模块,但是你可以只在引用web.config的时候使用它,而不需要修改任何代码。
Edit2:如果你想使用重写规则,你必须改变你的模式,如下所示:
<rule name="Prevent SWF hotlinking" enabled="true">
<match url="/ContentCache/.*\.swf$" ignoreCase="true" />
<conditions>
<add input="{HTTP_REFERER}" pattern="^http://(.*\.)?myurl\.com/.*$" negate="true" />
</conditions>
<action type="Rewrite" url="/Content/Flash/NoEmbedFromCacheSWF.swf" />
</rule> 使用的模式是一个正则表达式,你可以在here上阅读它们,你可以在this webpage上测试它们。
https://stackoverflow.com/questions/10031675
复制相似问题