IIS Rewrite remove WWW rule

non www

IIS üzerinde www yönlendirmeyi kaldıran web.config dosyasına yazılan efsane kod.

IIS Rewrite remove WWW rule

<system.webServer>
    <rewrite>
      <rules>
        <rule name="Remove WWW" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
          </conditions>
          <action type="Redirect" url="http://{C:2}{PATH_INFO}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

HTTP TO HTTPS kodu da ekstra olarak yazdım. Rules içine yazarak ekleyebilirsiniz.

 <rule name="httptohttps" enabled="true" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$" />
                    </conditions>
                    <action type="Redirect" url="https:{HTTP_HOST}{R:1}" />
                </rule>

301 IIS Rewrite Module for Legacy URLS

<system.webServer> 
    <rewrite>
      <rules>
        <rule name="Redirect rule for Redirects">
          <match url=".*" />
          <conditions>
            <add input="{Redirects:{REQUEST_URI}}" pattern="(.+)" />
          </conditions>
          <action type="Redirect" url="{C:1}" appendQueryString="false" />
        </rule>
      </rules>
      <rewriteMaps>
        <rewriteMap name="Redirects">
          <add key="/work.aspx" value="/our-work" />
          <add key="/services.aspx" value="/services" />
          <add key="/default.aspx" value="/" />
        </rewriteMap>
      </rewriteMaps>
    </rewrite>
  </system.webServer>

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Solve : *
26 + 7 =