Redirect 301 with Webconfig

Asked

Viewed 125 times

1

I use a rule that works more does not seem correct. I think it ends up giving two redirect 301.

            <!--Forçar https-->
            <rule name="Https" stopProcessing="true">
              <match url="^" ignoreCase="false" />
              <conditions>
                <add input="{HTTP_X_FORWARDED_PROTO}" pattern="https" ignoreCase="false" negate="true" />
                <add input="{HTTPS}" pattern="off" ignoreCase="false" />
              </conditions>
              <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}{URL}" />
            </rule>
            <!--Forçar Www-->
            <rule name="Www" stopProcessing="true">
                  <match url="^(.*)" ignoreCase="false" />
                  <conditions>
                    <add input="{HTTP_HOST}" pattern="^(site\.com\.br)(:80)?" />
                  </conditions>
                  <action type="Redirect" redirectType="Permanent" url="https://www.site.com.br/{R:1}" />
            </rule>

The first is to force https and the second force www. How to assemble a single rule that does both. It has to be on the web.config itself.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.