How to Force or Remove WWW on an IIS Site

Plesk Servers > IIS
If you would like to force or remove the WWW in the URL for your domain name for SEO or SSL reasons you may do so using the steps below. 

Forcing WWW
  1. Connect to your site's web.config file.  If you are unsure of how to do this please refer to our How to Access Your Web.Config article.
  2. Scroll down until you find the <system.webserver> or </handlers> line and just below it, press enter to add a new line.
  3. Paste the following code at the new line:
    <rewrite>
      <rules>
       <clear />
        <rule name="WWW Rewrite" enabled="true">
          <match url="(.*)" />
            <conditions>
              <add input="{HTTP_HOST}" negate="true" pattern="^www\.(.*)$" />
            </conditions>
            <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
    
  4. Save the web.config.

Remove WWW

  1. Connect to your site's web.config file.  If you are unsure of how to do this please refer to our How to Access Your Web.Config article.
  2. Scroll down until you find the <system.webserver> or </handlers> line and just below it, press enter to add a new line.
  3. Paste the following code at the new line:
    <rewrite>
      <rules>
        <rule name="Remove WWW" stopProcessing="true">
          <match url=".*" ignoreCase="true" />
          <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="^www\.(.*)$" />
          </conditions>
          <action type="Redirect" url="http://{C:1}/{R:0}" appendQueryString="true" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
    
  4. Save the web.config

Add Feedback