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 これは、Azure ストレージにリダイレクトする必要があります....

ストレージ上の画像の 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 に答える