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" /> </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" /> </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类型的文件。
