[英]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.