[英]IIS Rewrite rule - if path does not have query string
How do I write IIS Rewrite rule if path does not have query string and any capital letter exists in path then redirect to same path with lower case
? if path does not have query string and any capital letter exists in path then redirect to same path with lower case
如何编写IIS重写规则?
eg 例如
http://localhost:62871/Second.aspx/Test?X=Y http:// localhost:62871 / Second.aspx / Test?X = Y
redirects to: http://localhost:62871/second.aspx/test?X=Y 重定向到: http:// localhost:62871 / second.aspx / test?X = Y
Following rule works but it lower cases the querystring too: 遵循规则有效,但也会小写查询字符串:
<rewrite>
<rules>
<rule name="LowerCaseRule1" stopProcessing="true">
<match url="[A-Z]" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{URL}}" />
</rule>
</rules>
</rewrite>
The variable URL
contains the entire url - so ToLower
is lower casing the entire url. 变量
URL
包含整个ToLower
因此ToLower
在整个URL的下方ToLower
。
To get the desired behaviour you need to create the action
's url manually from multiple server variables. 要获得所需的行为,您需要从多个服务器变量手动创建
action
的url。
Available variables include {HTTP_HOST}
, {PATH_INFO}
and {QUERY_STRING}
, you can then apply the lowercase function to whichever variables you require. 可用变量包括
{HTTP_HOST}
, {PATH_INFO}
和{QUERY_STRING}
,然后可以将小写函数应用于所需的任何变量。
When creating the final url you also need to include the seperators :
, /
, ?
创建最终URL时,还需要包括分隔符
:
, /
, ?
between the variables to get a valid url. 在变量之间获取有效的网址。
See this page for quick overview of variables: https://weblogs.asp.net/owscott/url-parts-available-to-url-rewrite-rules 请参阅此页面以快速了解变量: https : //weblogs.asp.net/owscott/url-parts-available-to-url-rewrite-rules
See here for full rewrite module docs: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference 有关完整的重写模块文档,请参见此处: https : //docs.microsoft.com/zh-cn/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.