阅:11 | 回:0 | IIS网站文件图片防盗链设置教程 |
鱼鱼 | 发表于 2024-12-23 10:16:08 |
![]()
|
首先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> 以萌养阵,方可长命百岁。 ![]() |