我正在使用urlrewriting.net重定向一个级联样式表映像请求。我一直在尝试这样做,但没有运气。下面是我添加的重写代码:
<add name="reportImagesRedirect"
virtualUrl="^~/estadisticas/(.*).png"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/images/$1"
ignoreCase="true" />我想知道它是不是出了什么问题。我正在尝试将所有http get请求链接到一个文件夹,以便重定向到图像文件夹。例如,当我提出这样的请求时
http://localhost:8080/estadisticas/spines.png
我想让web服务器查看图像
http://localhost:8080/images/spines.png
发布于 2010-01-24 13:29:15
你需要把它翻过来。
<add name="reportImagesRedirect"
destinationUrl="~/images/$1.png"
rewriteUrlParameter="ExcludeFromClientQueryString"
virtualUrl="^~/estadisticas/(.+).png$"
ignoreCase="true" />Here是我写的一篇关于在无扩展网址中使用UrlRewriting.Net的小文章。
编辑:我稍微修改了一下参数。如果要保留扩展名,则需要在虚拟和目标的末尾都具有.png
编辑:您可能还需要对system.webServer标记进行以下修改
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
</modules>
</system.webServer>发布于 2010-01-24 13:36:11
您可能需要设置wildcard mapping。除了ASP.NET文件(.aspx、.asmx、.axd、.ashx等),IIS不会转发任何请求。默认情况下添加到ASP.NET处理程序。由于重写器在ASP.NET处理程序中运行,因此对图像的请求永远不会到达它。添加通配符映射会强制IIS让ASP.NET (以及重写处理程序)处理所有请求,包括图像。
https://stackoverflow.com/questions/2126076
复制相似问题