<rewrite>
<rules>
<clear/>
<rule name="photo path rewrite" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{QUERY_STRING}" pattern="/photos/20/(.*)" />
</conditions>
<action type="Redirect" url="{HTTP_HOST}/photos/20_new/{C:1}" redirectType="Temporary" />
</rule>
</rules>
<rewriteMaps></rewriteMaps>
</rewrite>
您能解释一下您要重定向的URL属于src属性还是只想直接访问该URL?
如果直接访问URL,则只需将条件输入从{QUERY_STRING}更改为{REQUEST_URI}。
如果此url属于html img标签中的“ src”属性,则可以尝试此出站规则。
<rewrite>
<outboundRules>
<rule name="outbound rule" preCondition="IsImage">
<match filterByTags="Img" pattern="(.*)" />
<conditions>
<add input="{REQUEST_URI}" pattern="/photos/20/(.*)" />
</conditions>
<action type="Rewrite" value="{HTTP_HOST}/photos/20_new/{C:1}" />
</rule>
<preConditions>
<preCondition name="IsImage">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>