简体   繁体   中英

IIS 7.5 UrlRewrite rule for 301 redirect to lowercase url

I need a Url-rewrite rule to make a 301-redirect to url in lowercase. For example http://example.com/CurRENcies/USD should become http://example.com/currencies/usd .

I have the following rewrite rule:

<rule name="LowerCaseRule1" stopProcessing="true">
<match url="[A-Z]" ignoreCase="false" />
<action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent"/>
</rule>

How can I do this redirects only for GET requests?

Try this:

<rule name="LowerCaseRule1" stopProcessing="true">
<match url="^.*[A-Z]+.*$" ignoreCase="false" />
<conditions>
   <add input="{REQUEST_METHOD}" matchType="Pattern" pattern="GET" ignoreCase="true" />
</conditions>
<action type="Redirect" url="{ToLower:{URL}}" redirectType="Permanent"/>
</rule>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM