Полезное‎ > ‎Хостинг‎ > ‎

301 Redirect Http на Https IIs7

Redirect non-www urls to www urls in IIS
Нужно  в web.config прописать

<configuration>

    <system.webServer>

        <rewrite>

            <rules>

               <rule name="Redirect to https">
               <match url="(.*)" />
                <conditions>
                    <add input="{SERVER_PORT}" pattern="443" negate="true" />
                </conditions>
                 <action type="Redirect" url="https://www.yourdomain.com/{R:1}" />
              </rule>
            </rules>

        </rewrite>

    </system.webServer>

</configuration>



Redirect www urls to non-www urls in IIS

<rewrite>
     
<rules>
       
<rule name="Imported Rule 1" stopProcessing="true">
         
<match url="^(.*)$" ignoreCase="false" />
         
<conditions logicalGrouping="MatchAll">
           
<add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
         
</conditions>
         
<action type="Redirect" url="http://{C:1}/{R:1}" redirectType="Permanent" />
       
</rule>
     
</rules>
   
</rewrite>
Comments