[英]IIS 10 rule rewrite not working with pho
我有一台IIS10服務器,並在該服務器上運行php應用程序。 一切工作正常,我安裝了IIS重寫,並且對於一個規則(即規范的主機名)工作正常。 但是,我還有一條規則,我希望限制對目錄中特定圖像的訪問,除非請求僅來自一個特定的php頁面,並且具有以下規則。 無論我如何嘗試,任何人仍然可以直接在www.mydomain.com/pics/imagename.jpg上瀏覽圖像。我使用了重寫模塊中的測試URL功能,並且為jpg鏈接和允許的頁面通過了測試,因此我我有信心這沒錯。
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^www\.domain\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.domain.com/{R:1}" />
</rule>
<rule name="RestrictHotlinking" patternSyntax="Wildcard" stopProcessing="false">
<match url="*/pictures/*.jpg" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_REFERER}" pattern="http*://www.domain.com/OneAllowedPage.php*" negate="true" />
</conditions>
<action type="Rewrite" url="www.domain.com/img/placeholder.jpg" appendQueryString="false" />
</rule>
</rules>
</rewrite>
實際發現了問題。 看起來這是一個額外的正斜線。下面的兩個小更改解決了該問題。 該條件的第一個匹配部分的網址似乎表示www.domain.com/**ThisPartOnly**
之后的內容
<match url="*pictures/*.jpg" />
<action type="Rewrite" url="img/placeholder.jpg" ppendQueryString="false" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.