我正在使用URLRewriter,但有一个问题,它重写了所有地址,甚至是图像URL,例如,它显示了http://localhost/images/logo.png的网页。
这是我的web.config
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="rewriter"
requirePermission="false"
type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
</httpModules>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<rewriter>
<rewrite url="~/pages/(.+)" to="~/default.aspx?pn=$1" />
</rewriter>
</configuration>我希望它只重写.aspx文件。
发布于 2011-11-18 05:40:54
重写元素中的url属性是一个页面,此时您拥有的表达式匹配~/ .Net regular expression /下的任何内容。如果您只想匹配.aspx文件,最简单的做法是将其更改为:
<rewrite url="~/pages/(.+\.aspx)" to="~/default.aspx?pn=$1" />https://stackoverflow.com/questions/8174149
复制相似问题