简体   繁体   中英

Single Rule for lowercase WWW HTTPs in IIS URL Rewrite

I am trying to create a SINGLE rewrite rule (to avoid multiple 301 redirects) that would turn all requests to https, lowercase, www-prefixed.

So, http://example.com/Page would be https://www.example.com/page - all within a single rule.

How can I do this?

<rule name="All in one URL" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAny">
        <add input="{HTTPS}" pattern="off" />
        <add input="{REQUEST_URI}" pattern="[A-Z]" ignoreCase="false" />
        <add input="{HTTP_HOST}" pattern="^www\." negate="true" />
     </conditions>
     <action type="Redirect" url="https://www.example.com:35077{ToLower:{URL}}" />
</rule>

This rule will do this tricks:

  • Lowercase URL
  • Force to HTTPS
  • Prepend www if necesary

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