【发布时间】:2014-04-08 17:20:31
【问题描述】:
我在运行 Windows Server 2012 R2 的 Web 服务器上安装了 URL 重写模块,其 URL 如下:http://staging.mysite.net/
我将图像、字体、脚本等加载到 Azure CDN。
我在我的 Web.config 中指定了以下规则:
<rewrite>
<rules>
<rule name="CDN: fonts" stopProcessing="true">
<match url="^fonts/(.*)" />
<action type="Rewrite" url="http://cdn.staging.mysite.net/fonts/{R:1}" appendQueryString="true" />
</rule>
<rule name="CDN: images" stopProcessing="true">
<match url="^images/(.*)" />
<action type="Rewrite" url="http://cdn.staging.mysite.net/images/{R:1}" appendQueryString="true" />
</rule>
<rule name="CDN: pdf" stopProcessing="true">
<match url="^pdf/(.*)" />
<action type="Rewrite" url="http://cdn.staging.mysite.net/pdf/{R:1}" appendQueryString="true" />
</rule>
<rule name="CDN: scripts" stopProcessing="true">
<match url="^scripts/(.*)" />
<action type="Rewrite" url="http://cdn.staging.mysite.net/scripts/{R:1}" appendQueryString="true" />
</rule>
<rule name="CDN: style" stopProcessing="true">
<match url="^style/(.*)" />
<action type="Rewrite" url="http://cdn.staging.mysite.net/style/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
即使文件存在,所有内容都作为 404 错误返回。例如,我的页面引用了 /images/en-us/logo.png。我验证了 http://cdn.staging.mysite.net/images/en-us/logo.png 确实存在。
此外,Url Rewrite snap in 的“测试模式”功能显示,当您输入 images/en-us/logo.png 时,{R1} 返回 en-us/logo.png em> 或 /images/en-us/logo.png 进入“Input data to test”字段。
我暂时尝试过使用 type="Redirect" 而不是 type="Rewrite" 但这会导致来自服务器的重复请求/响应。第一个是 301,第二个是 200。我只想要 200 响应。
++ 显然,mysite.net 并不是我真正的域,仅用于示例目的。
【问题讨论】:
标签: iis azure url-rewrite-module azure-cdn