Knowledgebase: Windows Hosting
IIS web.config How to redirect www.domain.com to domain.com
Posted by Premium Reseller on 30 June 2014 08:51 PM

IIS rewrite rules to redirect www.yourdomain.com to yourdomain.com

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Redirect to non-www" stopProcessing="true">
          <match url="(.*)" negate="false"></match>
          <conditions>
            <add input="{HTTP_HOST}" pattern="^yourdomain\.com$" negate="true"></add>
          </conditions>
          <action type="Redirect" url="http://yourdomain.com/{R:1}" redirectType="Permanent"></action>
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

(2 vote(s))
This article was helpful
This article was not helpful