asp.net - 小写 URL 的 IIS 重写规则

标签 asp.net iis url-rewriting

我有一个 IIS 重写规则来将所有 URL 转换为小写

<rewrite>
    <rules>
        <rule name="LowerCaseRule1" stopProcessing="true">
            <match url="[A-Z]" ignoreCase="false" />
            <action type="Redirect" url="{ToLower:{URL}}" />
        </rule>
    </rules>
</rewrite>

但是它只将部分 url 转换为小写,而不转换查询字符串。例如 ID 不转换为 id

http://www.itsmysitesitesite.com/showproduct.aspx?ID=230

如何修改上述规则以包含查询字符串?

最佳答案

根据我的评论(引用 this 问题),我想规则看起来像这样:

<rule name="URL Lower" enabled="true" stopProcessing="true">
      <match url="[A-Z]" ignoreCase="false" />                        
      <conditions trackAllCaptures="true">
          <add input="{QUERY_STRING}" pattern="(.*)" />
          <add input="{QUERY_STRING}" pattern="([A-Z]+)" ignoreCase="false" />
      </conditions>
      <action type="Redirect" url="{ToLower:{URL}}{ToLower:{C:1}}" appendQueryString="false" />
 </rule>

但免责声明,我在 Windows XP 上工作,所以我只有 IIS 6.0,所以我无法检查语法是否正确!可能需要一些调整...

关于asp.net - 小写 URL 的 IIS 重写规则,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20267341/

相关文章:

asp.net - 将变量分配给 Repeater 值

sql - 使用 iis 托管 .net 核心应用程序会出现数据库访问错误

performance - IIS Web花园和性能

c# - 如何在 Url Rewriting 中用 - 替换 %20

r - 对一组 URL 发出并发 RCurl GET 请求

asp.net - 在 SSL 终止反向代理后面运行时如何在 IIS 上创建重定向响应?

asp.net - 使用 asp.net 按钮启动 html 代码

iis - 创建 SDDL 失败,错误 : 1332

regex - Url Rewrite HTTPS -> HTTP 特定页面除外 (IIS 7)

javascript - 将 toLocaleString 应用于具有特定类的所有动态文本框