2017-01-16 40 views
0

我有一个IIS10服务器,并且我正在运行一个PHP应用程序。一切工作都很好我已经安装了IIS重写,并且它适用于规范主机名的一个规则。然而,我还有一个规则,我想限制访问目录中的特定图像,除非请求来自一个特定的PHP页面,并且我有以下规则。无论我尝试什么任何人都可以直接在www.mydomain.com/pics/imagename.jpg上浏览图片 我在重写模块中使用了测试URL功能,并且我的测试通过了jpg链接和允许的页面,所以我我相信这没什么不妥。IIS 10规则重写不能与pho

<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> 

回答

0

居然发现了这个问题。看起来像是一个额外的正斜杠 下面的两个小改变解决了这个问题。看起来,该条件的第一个MATCH Parth的URL意味着什么后www.domain.com/**ThisPartOnly**

<match url="*pictures/*.jpg" /> 
    <action type="Rewrite" url="img/placeholder.jpg" ppendQueryString="false" />