如何编写IIS重写规则if path does not have query string and any capital letter exists in path then redirect to same path with lower case
例如:
http://localhost:62871/Second.aspx/Test?X=Y
重定向到:http://localhost:62871/second.aspx/test?X=Y
下面的规则起作用了,但它在更低的情况下使用了查询字符串:
<rewrite>
<rules>
<rule name="LowerCaseRule1" stopProcessing="true">
<match url="[A-Z]" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{URL}}" />
</rule>
</rules>
</rewrite>发布于 2018-07-13 12:29:41
变量URL包含整个url -因此ToLower是小写的整个url。
要获得所需的行为,需要手动从多个服务器变量创建action的url。
可用变量包括{HTTP_HOST}、{PATH_INFO}和{QUERY_STRING},然后可以将小写函数应用于所需的变量。
在创建最终的url时,还需要在变量之间包含分隔符:、/、?,以获得有效的url。
有关变量的快速概述,请参阅此页面:https://weblogs.asp.net/owscott/url-parts-available-to-url-rewrite-rules
有关完整的重写模块文档,请参见此处:https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference
https://stackoverflow.com/questions/51318631
复制相似问题