Wednesday, August 28, 2019

Redirect rules

 <rewrite>
      <rules>
        <rule name="Sitecore Login or Admin Force HTTPS Redirection" enabled="true" stopProcessing="true">
          <match url="^(sitecore/(login|admin))$" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
            <add input="{HTTP_METHOD}" pattern="GET" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
        </rule>
        <rule name="Forbidden" enabled="true" stopProcessing="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
            <add input="{HTTP_METHOD}" pattern="GET" />
          </conditions>
          <action type="CustomResponse" statusCode="403" subStatusCode="0" />
        </rule>
<--this rule below will remove www. from the url -->
        <rule name="Remove www" stopProcessing="true">
  <match url="(.*)" ignoreCase="true" />
  <conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
  </conditions>
  <action type="Redirect" url="https://{C:1}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
      </rules>
    </rewrite>
  </system.webServer>
  <system.web>

No comments:

Post a Comment