C
C
cicatrix2018-03-16 10:40:44
ASP.NET
cicatrix, 2018-03-16 10:40:44

How to add exception to rewrite rules in web.config?

Good afternoon.
I have this design in web.config to redirect all traffic to https (copy-paste from what the host gave me).
I need to exclude from this rule everything that goes to /api/*
As I understand it, add something to match, but I don’t understand how.
How can I do that?

<system.webServer>
    <rewrite>
      <rules>
        <rule name="HTTP to HTTPS redirect" stopProcessing="true">
          <conditions>
            <add input="{HTTP_X_Forwarded_Proto}" negate="true" pattern="^https$" ignoreCase="true" />
          </conditions>
          <match url="(.*)" />
          <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question