我有一个 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/