The Software Artist | Code is a form of art.

May/10

16

Removing www from your host URLs in IIS 7

Here are some instructions to redirect all requests to http://www.hostname.com to just http://hostname.com. There are a few reasons why you would want to do this, here is a good post explaining some reasons why, and how to redirect from http://hostname.com to http://www.hostname.com. Doing the opposite is just as simple, add this to your web.config:

  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Redirect to remove WWW" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^www.hostname.com$" />
          </conditions>
          <action type="Redirect" url="http://hostname.com/{R:0}" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>

·

1 comment

Leave a Reply

>>

Theme Design by devolux.nh2.me