How to Force or Remove WWW on an IIS Site

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 for Plesk or IIS web.config. 
 
Plesk 12.5 and up
The steps below assume that you are already logged into the Plesk Control panel
  1. While on the Websites & Domains tab, select Hosting Settings


     
  2. While on the Hosting Settings page, select the preferred domain you wish to force or remove the 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

Related KB Articles:
How to Force SSL on an IIS Site

Add Feedback