我有一個在IIS中創建的網站,根網站共享有一些子文件夾,用於分發網頁正在使用的圖像,CSS,js文件。但是,如果用戶知道圖像名稱,則可以訪問圖像(http://hello.com/images/abc.jpg)。IIS禁止直接訪問圖像
有什麼辦法可以禁用資源的直接訪問嗎?請注意,我剛開始學習asp.net,所以如果答案可能有點描述性,那將會很棒。
我已經開始瞭解URL重寫方法,但是如何無法使其工作。
編輯:我把這個web.config放在我的images文件夾中,現在它做相反的事情,屏蔽頁面上的圖像並直接允許它們。 任何幫助表示讚賞。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<identity impersonate="true" />
</system.web>
<system.webServer>
<rewrite>
<rules>
<rule name="RequestBlockingRule1" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*\.(gif|jpg|png)$" />
<conditions>
<add input="{HTTP_REFERER}" pattern="^$" negate="true" />
<add input="{HTTP_REFERER}" pattern=" http://iolab023/.*" negate="true" />
</conditions>
<action type="CustomResponse" statusCode="403" statusReason="Forbidden: Access is denied." statusDescription="You do not have permission to view this directory or page using the credentials that you supplied." />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>