What's wrong with IIS7 rewrite rule

I'm trying to do a simple redirect from the www subdomain to the root domain. After trying many variations, I'm stuck and hoping for help. Feeling sure it's something stupid, but can't see it. Here's the rule I'm using.

<rewrite>
  <rules>
    <rule name="Redirect to root" stopProcessing="true">
      <match url=".*"  />
      <conditions>
        <add input="{HTTP_HOST}" pattern="^www.stitchamerica.com$" negate="true" />
      </conditions>
      <action type="Redirect" url="http://stitchamerica.com/{R:1}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

Input greatly appreciated.

Answers


This works for me:

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

Need Your Help

receive xml file as a parameter to a .net web service

asp.net xml web-services

My company is currently looking into bringing a new piece of third party software in for online ordering. The software does not handle pricing so they are requesting the pricing information from a ...

C++ is creating a header to solve circular dependency a good idea?

c++ header-files circular-dependency

I have a C++ project that's starting to get big. I'm facing a situation where I have lots of classes with circular dependencies. Suppose I have classes A, B, C, D. To solve this, I've created a hea...