[英]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.