天空小小岛技术网站

标题: iis7 rewrite 防盗链设置 [打印本页]

作者: 八号    时间: 2011-8-16 20:40
标题: iis7 rewrite 防盗链设置
IIS7.0实现防盗链可以通过URL rewrite模块,将tkxxd.net改成你自己的域名然后保存为存为web.config,再将 web.config文件上传网站的根目录即可。如果已有web.config文件,只要将<rewrite>…</rewrite>这段代码添加到<system.webServer>和</system.webServer>之间。
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3.         <system.webServer>
  4.                 <rewrite>
  5.                 <rules>
  6.                         <rule name="Forbid image">
  7.                         <match url="\.(txt|doc|gif|jpg|jpeg|png|mp3|flv|swf)$" ignoreCase="false" />
  8.                         <conditions>
  9.                         <add input="{HTTP_REFERER}" pattern="^$" ignoreCase="false" negate="true" />
  10.                         <add input="{HTTP_REFERER}" pattern="^http://(www\.)?tkxxd.net/.*$" negate="true" />
  11.                         </conditions>
  12.                         <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
  13.                         </rule>
  14.                 </rules>
  15.                 </rewrite>
  16.         </system.webServer>
  17. </configuration>
复制代码
如果显示默认图片则将
  1. <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
复制代码
换成
  1. <action type="Rewrite" url="/static/image/common/logo.png" />
复制代码





欢迎光临 天空小小岛技术网站 (http://tkxxd.net/) Powered by Discuz! X3.1