跳到主要内容
帮助中心

新闻公告

产品更新、运营公告与行业观察
一手消息,第一时间同步给你

IIS网站文件图片防盗链设置教程

首先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>

本文链接
返回本栏目
工单