Rewrite image to cdn asp.net
Hướng dẫn rewrite file tĩnh image sang domain cdn trên asp.net
<outboundRules rewriteBeforeCache="true">
<!-- outbound rules -->
<rule name="CDN-01-jpg" preCondition="CheckHTML" stopProcessing="true">
<match
filterByTags="Img"
pattern="(^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*\.(jpg|jpeg|png).*)" />
<action type="Rewrite" value="https://cdn.domain.com{R:1}" />
</rule>
<preConditions>
<preCondition name="CheckHTML">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</outboundRules>
<!-- outbound rules -->
<rule name="CDN-01-jpg" preCondition="CheckHTML" stopProcessing="true">
<match
filterByTags="Img"
pattern="(^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*\.(jpg|jpeg|png).*)" />
<action type="Rewrite" value="https://cdn.domain.com{R:1}" />
</rule>
<preConditions>
<preCondition name="CheckHTML">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</outboundRules>
Chúc các bạn thành công.
Bình luận
Gửi