• rewrite2.0 设置防盗链,iis7.0+


    IIS7.0可以通过URL rewrite模块实现防盗链,复制下面的代码,将zdzz.net改成你自己的域名然后保存为存为web.config,再将 web.config文件上传网站的根目录即可。如果已有web.config文件,只要将<rewrite>…</rewrite>这段代码添加到<system.webServer>和< /system.webServer>之间。

    01 <?xml version="1.0" encoding="UTF-8"?>
    02 <configuration>
    03         <system.webServer>
    04             <rewrite>
    05                <rules>
    06                  <rule name="Forbid image">
    07                    <match url="\.(txt|doc|gif|jpg|jpeg|png|mp3|flv|swf)$" ignoreCase="false" />
    08                       <conditions>
    09                        <add input="{HTTP_REFERER}" pattern="^$" ignoreCase="false" negate="true" />
    10                        <add input="{HTTP_REFERER}" pattern="^http://(www\.)?fenggefushi.com/.*$" negate="true" />
    11                       </conditions>
    12                     <action type="Rewrite" url="/wp-content/uploads/forbid.png" />
    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="/images/nohotlinking.jpg" />

    images/nohotlinking.jpg根据你实际的图片位置和名称做修改。

  • 相关阅读:
    HDU 6034
    HDU 6047
    CodeForces 830B
    HDU 4972
    HDU 4408
    CodeForces 788B
    CodeForces 788A
    CodeForces 792C
    uva 1658 Admiral 最小费最大流
    hdu 5391 Zball in Tina Town 威尔逊定理
  • 原文地址:https://www.cnblogs.com/buaaboyi/p/2052263.html
Copyright © 2020-2023  润新知