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
武林網(wǎng)之家下載://www.iis7.com/softs/479310.html
2、修改網(wǎng)站的web.config或用記事本制作一個web.config,記住將*txt格式改為.config 代碼如下:
<system.webServer> <rewrite> <rules> <rule name="Prevent hotlinking"> <match url="^.*/.(rar|zip|7z)$" ignoreCase="true" /> <conditions> <add input="{HTTP_REFERER}" pattern="http://www.iis7.com/.*" 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.iis7.com、http://wt.jb51.net調(diào)用網(wǎng)站的rar、zip類型的文件。
將以上文件上傳至網(wǎng)站根目錄(wwwroot)下即可 如果網(wǎng)站有設置偽靜態(tài),直接將上述代碼加入原有web.config一樣可以生效
武林網(wǎng)之家小編注:上面的內(nèi)容需要放在<configuration>里面。例如如下是完整的
<?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="http://www.iis7.com/.*" 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>
為了更深入的學習,希望大家繼續(xù)看一下下面的圖文教程
主要是簡單介紹一下url重寫的配置,如果上面的規(guī)則放置位置沒問題,打開url重寫
看如下圖所示內(nèi)容沒問題就說明配置文件正常,否則按照上面武林網(wǎng)之家給出的完整示例修改即可
配置過程中的測試
模式:^.*/.(rar|zip|7z)$
編輯條件:
{HTTP_REFERER}
與模式不匹配(才觸發(fā)條件)
模式:網(wǎng)址匹配(//www.iis7.com/.*
)單獨的www域名,如果更多的二級域名呢
武林網(wǎng)之家小編更喜歡
新聞熱點
疑難解答
圖片精選