iis - srcset 的 IIS 出站重写规则仅重写一次
问题描述
我在 II 上创建一个 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 属性中的所有值?
解决方案
您可以使用以下重写规则:
<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>
问候,贾尔帕。
推荐阅读
- python - 在一个 pyhton 模块中定义的命名元组无法被另一个 python 模块识别
- c++ - 在 C++ 中使用特定密码设置 openssl 客户端
- ios - 在苹果购买历史中,应用内购买待定状态更改为成功需要多长时间
- java - 未找到 Java FutureOrPresent 验证实现
- python - 如何从 netcdf 文件中提取投影在不规则网格上的变量的像素值?
- spring-security - Spring Security 只允许访问自己的资源
- amazon-web-services - 我可以在 AWS Fargate 中执行日志运行控制台应用程序吗
- mysql - 将 TSV 文件从存储桶移动到 Cloud MySql
- angular - 如何使用打字稿中的装饰器向类添加和声明新属性(角度)
- scalafmt - scalafmt 配置类似于 IntelliJ 配置