[英]IIS Rewrite rule - if path does not have query string
if path does not have query string and any capital letter exists in path then redirect to same path with lower case
如何编写IIS重写规则?
例如
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>
变量URL
包含整个ToLower
因此ToLower
在整个URL的下方ToLower
。
要获得所需的行为,您需要从多个服务器变量手动创建action
的url。
可用变量包括{HTTP_HOST}
, {PATH_INFO}
和{QUERY_STRING}
,然后可以将小写函数应用于所需的任何变量。
创建最终URL时,还需要包括分隔符:
, /
, ?
在变量之间获取有效的网址。
请参阅此页面以快速了解变量: https : //weblogs.asp.net/owscott/url-parts-available-to-url-rewrite-rules
有关完整的重写模块文档,请参见此处: https : //docs.microsoft.com/zh-cn/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.