2014-01-13 128 views
1

我使用此代碼,以防止圖像熱鏈接不過IIS防止圖像盜鏈,HTTP和HTTPS

<rule name="Prevent Hotlinking"> 
    <match url=".*\.(jpg|jpeg|png|gif|bmp)$"/> 
    <conditions> 
     <add input="{HTTP_REFERER}" pattern="^$" negate="true" /> 
     <add input="{HTTP_REFERER}" pattern="^http://domain\.com/.*$" negate="true" /> 
    </conditions> 
    <action type="Rewrite" url="/img/hotlink-logo.png" appendQueryString="false" /> 
</rule> 

但是當我訪問HTTPS部分我所有的圖像都與盜鏈-logo.png替換。我嘗試添加第二個規則來管理hTTPS請求,但同樣的問題發生。

我試着爲HTTPS添加第二個條件,但是再次允許盜鏈。

有什麼建議嗎?由於

回答

2

您需要包括在正則表達式的網址:

^https?://domain\.com/.*$ 
+0

啊......偉大工程。謝謝 – puks1978