zoukankan      html  css  js  c++  java
  • win2008 IIS7.5防盗链配置方法

    1、下载微软自己提供的IIS REWRITE模块

    64位:
    http://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=1b8c7bd8-8824-4408-b8fc-49dc7f951a00
    32位:
    http://www.microsoft.com/zh-cn/download/details.aspx?id=5747

    脚本之家下载://www.jb51.net/softs/479310.html

    2、修改网站的web.config或用记事本制作一个web.config,记住将*txt格式改为.config 代码如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <system.webServer>
    <rewrite>
    <rules>
    <rule name="Prevent hotlinking">
    <match url="^.*.(rar|zip|7z)$" ignoreCase="true" />
    <conditions>
    <add input="{HTTP_REFERER}" pattern="//www.jb51.net/.*" negate="true" />
    <add input="{HTTP_REFERER}" pattern="http://wt.jb51.net/.*" negate="true" />
    </conditions>
    <action type="Rewrite" url="/no.html" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>

    设置了只允许//www.jb51.net、http://wt.jb51.net调用网站的rar、zip类型的文件。
    将以上文件上传至网站根目录(wwwroot)下即可 如果网站有设置伪静态,直接将上述代码加入原有web.config一样可以生效

    脚本之家小编注:上面的内容需要放在<configuration>里面。例如如下是完整的

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
      <system.webServer>
        <staticContent>
          <mimeMap fileExtension=".*" mimeType="appliction/force-download" />
        </staticContent>
        <httpErrors>
          <remove statusCode="404" subStatusCode="-1" />
          <error statusCode="404" prefixLanguageFilePath="" path="404.htm" responseMode="File" />
        </httpErrors>
        <rewrite>
            <rules>
            <rule name="Prevent hotlinking">
            <match url="^.*.(rar|zip|7z)$" ignoreCase="true" />
                <conditions>
                    <add input="{HTTP_REFERER}" pattern="//www.jb51.net/.*" negate="true" />
                    <add input="{HTTP_REFERER}" pattern="http://m.jb51.net/.*" negate="true" />
                    <add input="{HTTP_REFERER}" pattern="http://www.baidu.com/.*" negate="true" />
                </conditions>
            <action type="Rewrite" url="/daolian.htm" />
            </rule>
            </rules>
        </rewrite>
      </system.webServer>
    </configuration>

    .....................................................................

    篇2:

    首先,要下载、安装一个IIS 重写模块。是到微软站点下载的,可以放心了。(靠,之前以为IIS7是内置了的,想不到还是要另外安装东西)

    64位:

    http://www.microsoft.com/downloads/zh-cn/details.aspx?familyid=1b8c7bd8-8824-4408-b8fc-49dc7f951a00

    32位:

    http://www.microsoft.com/zh-cn/download/details.aspx?id=5747

    安装完以后,修改网站的web.config,加入

    <system.webServer>
    <rewrite>
    <rules>
    <rule name="Prevent hotlinking">
    <match url="^.*.(rar|zip)$" ignoreCase="true" />
    <conditions>
    <add input="{HTTP_REFERER}" pattern="http://www.fuqi800.com/.*" negate="true" />
    <add input="{HTTP_REFERER}" pattern="http://sims.fuqi800.com/.*" negate="true" />
    <add input="{HTTP_REFERER}" pattern="http://www.hudie.la/.*" negate="true" />
    </conditions>
    <action type="Rewrite" url="/404.htm" />
    </rule>
    </rules>
    </rewrite>
    </system.webServer>


    文件中设置了只允许http://www. fuqi800.com、http://sims. fuqi800.com、http://www. hudie.la调用网站的rar、zip类型的文件。

  • 相关阅读:
    AGC 044 A
    example
    python3遇到的问题
    构建开发环境
    pandas处理数据
    pandas.DataFrame对象解析
    pandas再次学习
    监督式学习
    机器学习的基础概念
    赖世雄老师的音标课,旋元佑老师的语法书
  • 原文地址:https://www.cnblogs.com/keringing/p/10441433.html
Copyright © 2011-2022 走看看