感谢您的关注,我们一直致力于为您提供放心、满意的服务。
首先IIS需要安装伪静态组件URL Rewrite,然后将代码保存为web.config,修改其中允许调用的域名,把它存放到网站根目录中,即可生效。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Prevent hotlinking">
<match url="^.*\.(jpg|png|mp4|rar|zip)$" ignoreCase="true" />
<conditions>
<add input="{HTTP_REFERER}" pattern="http://允许外部调用的域名/.*" negate="true" />
<add input="{HTTP_REFERER}" pattern="http://绑定的域名/.*" negate="true" />
</conditions>
<action type="Rewrite" url="/404.htm" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>