为什么这个图片网址重写规则不起作用?

时间:2018-03-03 04:35:42

标签: asp.net azure url-rewriting web-config imageurl

我已经写了一个URL重写来修复图像路径以移动到图像的新位置但是它不起作用。

<rule name="Artist Images" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{URL}" pattern="^/images/$" />
      </conditions>
      <action type="Rewrite" url="https://myserver.blob.core.windows.net/v2/images/" redirectType="Permanent" />
    </rule>

预期的行为是当图像请求(http://myserver.com/images/sample.jpg)出现新图像位置时 (https://myserver.blob.core.windows.net/v2/images/sample.jpg)被使用。

它是Azure上托管的.net应用程序。规则在web.config中 有什么想法吗?

2 个答案:

答案 0 :(得分:1)

由于您的条件不正确,您将放置符号$,这意味着字符串的结尾,但这不正确。

<rule name="Artist Images" stopProcessing="true">
  <match url="^images/(.*)$" />
  <action type="Rewrite" url="https://myserver.blob.core.windows.net/v2/images/{R:1}" />
</rule>

答案 1 :(得分:0)

这是最终工作的结果,但阿列克谢的答案使我们朝着正确的方向前进。

          

import venvdotapp; venvdotapp.require_bundle()
相关问题