[英]Webconfig inbound rule to avoid showing js files
我創建了以下規則
<rule name="block js files">
<match url=".*\.(js)/*$"/>
<action type="Redirect" url="http://{SERVER_NAME}/notfound/{R:1}" redirectType="notFound"/>
</rule>
這會將對 js 文件的請求移動到某個未找到的頁面。 這工作正常。
但是當它也阻止了應用程序請求的 js 文件時。
我認為從應用程序請求的 js 文件位於出站規則之下。
所以我想把我的上述規則放在入站部分,因為我相信來自瀏覽器的請求屬於入站規則。
我應該在這里更新什么?
謝謝
我認為您可以將您的域從HTTP_REFERER列入白名單。 因此,無論是從外部訪問 js 還是直接訪問它,IIS 都會重定向請求。 同時,IIS 不會阻止來自您的域的請求。 當然,您可以啟用 CORS 標頭。
此外,“notFound”不是有效的重定向類型。 您在尋找“Found”而不是“notFound”嗎?
<rule name="block js files" enabled="true" stopProcessing="true">
<match url=".*\.(js)/*$" />
<action type="Redirect" url="http://{SERVER_NAME}/notfound/{R:1}" redirectType="Found" />
<conditions>
<add input="{HTTP_REFERER}" pattern="mydomain.com" negate="true" />
</conditions>
</rule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.