srcset的IIS Outbound Rewrite Rule仅重写一次

问题描述 投票:0回答:1

我有一个问题,在IIs上创建一个outboundRule来更改html中的文本。当它只改变最后一个匹配时,问题出在srcset属性中的img标记内。

我试过这个:

<outboundRules>
  <rule name="ReverseProxyOutboundRuleHTML" preCondition="ResponseIsHTML" enabled="true" patternSyntax="ECMAScript" stopProcessing="false">
    <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script, CustomTags" customTags="customTags" pattern="(.*)9999.99.99.99:8080(.*)" />
    <action type="Rewrite" value="{R:1}example.com{R:2}" />
  </rule>           
  <preConditions>
    <preCondition name="ResponseIsHTML"> 
      <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
    </preCondition>
  </preConditions>
  <customTags>
    <tags name="customTags">
      <tag name="img" attribute="srcset" />
      <tag name="meta" attribute="content" />
    </tags>
  </customTags>
</outboundRules>

似乎是正确的,但我的结果是:

<img 
src="http://example.com/wp-content/uploads/2019/02/Mercedes_ClasseV-1024x540.png" 
srcset="http://9999.99.99.99:8080/wp-content/uploads/2019/02/Mercedes_ClasseV-1024x540.png 1024w, http://9999.99.99.99:8080/wp-content/uploads/2019/02/Mercedes_ClasseV-300x158.png 300w, http://9999.99.99.99:8080/wp-content/uploads/2019/02/Mercedes_ClasseV-768x405.png 768w, http://example.com/wp-content/uploads/2019/02/Mercedes_ClasseV.png 1100w" 
sizes="(max-width: 750px) 100vw, 750px">

有什么帮助,要更改srcset属性中的所有值?

iis url-rewriting web-config
1个回答
0
投票

你可以使用下面的重写规则:

 <outboundRules>
  <rule name="ReverseProxyOutboundRuleHTML" preCondition="ResponseIsHTML" enabled="true" patternSyntax="ECMAScript" stopProcessing="false">
    <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script, CustomTags" customTags="customTags" pattern="(.*)9999.99.99.99:8080(.*),(.*)9999.99.99.99:8080(.*)\,(.*)9999.99.99.99:8080(.*)" />
    <action type="Rewrite" value="{R:1}example.com{R:2},{R:3}example.com{R:4},{R:5}example.com{R:6}" />
  </rule>           
  <preConditions>
    <preCondition name="ResponseIsHTML"> 
      <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
    </preCondition>
  </preConditions>
  <customTags>
    <tags name="customTags">
      <tag name="img" attribute="srcset" />
      <tag name="meta" attribute="content" />
    </tags>
  </customTags>
</outboundRules>

enter image description here

此致,Jalpa。

© www.soinside.com 2019 - 2024. All rights reserved.