UrlRewrite IIS使现有图像URL与ImageResizer一起使用 [英] UrlRewrite IIS to make existing image urls work with ImageResizer
问题描述
我们正在尝试将Imageresizer与磁盘缓存功能以及sqldatareader一起使用。它希望网址形式为:
We are trying to use Imageresizer with the disk cache feature as well as the sqldatareader. It expects urls to be in the form of:
http:/ /somesite.com/image/ {imageid}。{extension}
http://somesite.com/image/{imageid}.{extension}
而我们网站中的所有图片链接目前都是:
whereas all the image links in our site is currently:
http://somesite.com/image.aspx?imageid= {imageid}& format = {extension}
http://somesite.com/image.aspx?imageid={imageid}&format={extension}
到目前为止,我发现转换它们的最佳解决方案是UrlRewrite,但我们正好相反它的意图是什么(把好网址弄得很糟糕)。我一直在努力让重写规则正确,并希望有人可以提供帮助。以下是我目前的情况,我知道它可能完全错误:
The best solution I have found so far to convert these is UrlRewrite but we are kind of doing the opposite of what it intends (taking nice urls to nasty). I have been struggling to get the rewrite rule correct for this and was hoping that somebody could help. Below is what I currently have and am aware it may be completely wrong:
<rewrite>
<rules>
<rule name="RewriteUserFriendlyURL1" stopProcessing="true">
<match url="^image.aspx?([^imageid=]+)$" ignoreCase="true" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="false" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="image/{R:1}.jpg" />
</rule>
</rules>
</rewrite>
推荐答案
能够获得使用的基本功能以下规则。
Was able to get the basic functionality to work with the following rule.
<rule name="Redirect Category Name and Sort By" stopProcessing="true">
<match url="^image\.aspx$" ignoreCase="true" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="^imageid=([0-9]+)" />
</conditions>
<action type="Rewrite" url="image/{C:1}.jpg" appendQueryString="true" />
</rule>
这篇关于UrlRewrite IIS使现有图像URL与ImageResizer一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!