【问题标题】:Redirect directory to Azure url将目录重定向到 Azure url
【发布时间】:2012-12-08 06:09:19
【问题描述】:

我在 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

【问题讨论】:

标签: redirect azure azure-blob-storage


【解决方案1】:

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

<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 重写模块有一个很好的测试功能来测试你的正则表达式。

【讨论】:

    猜你喜欢
    • 2020-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-30
    相关资源
    最近更新 更多