2
votes

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?

1

1 Answers

2
votes
<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