2

我已经在 webconfig 中编写了这条规则,以将我在 thsi 文件夹中的所有资源重定向到我的 azure blob,但它没有在那里显示任何图像。

 <rule name="RewriteIncomingCdnRequest" stopProcessing="true">
      <match url="^/CDN/(.*)$" ignoreCase="false"/>
      <action type="Redirect" redirectType="Permanent" url="https://stplatformstorage.blob.core.windows.net/static/{R:0}" />
    </rule>

http://sttest.azurewebsites.net/CDN/image_cdn-trans.png 这应该重定向到天蓝色存储....

存储上的图像 url https://stplatformstorage.blob.core.windows.net/static/image_cdn-trans.png

4

1 回答 1

1

你有一个错误的正则表达式 - 如所写, url="^/CDN/(.*)$" 只会匹配 /CDN/image_cdn-trans.png - 因为“^” 表示“从...开始” -你真正需要的是 url=" ^.*/CDN/(.*)$" 然后使用匹配组 {R:1} - 用于:

<rule name="RewriteIncomingCdnRequest" stopProcessing="true">
  <match url="^.*/CDN/(.*)$" ignoreCase="false"/>
  <action type="Redirect" redirectType="Permanent" url="https://stplatformstorage.blob.core.windows.net/static/{R:1}" />
</rule>

URL Rewrite 模块有一个很好的测试功能来测试你的正则表达式。

于 2012-12-07T05:27:59.880 回答