天空小小岛技术论坛

 找回密码
 注册
搜索
查看: 6401|回复: 0
打印 上一主题 下一主题

iis7 rewrite 防盗链设置

[复制链接]
跳转到指定楼层
1#
八号 发表于 2011-8-16 20:40:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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" />
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|天空小小岛  |京ICP备2025130156号|

GMT+8, 2025-6-22 04:58 , Processed in 0.089597 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表