<p>I'm using <a href="http://www.helicontech.com/isapi_rewrite/" rel="nofollow noreferrer">Helicon's ISAPI Rewrite 3</a>, which basically enables .htaccess in IIS.  I need to redirect a non-www URL to the www version, i.e. example.com should redirect to www.example.com.  I used the following rule from the examples but it affects subdomains:</p>

<pre><code>RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]
</code></pre>

<p>This works for most part, but is also redirect sub.example.com to www.sub.example.com.  How can I rewrite the above rule so that subdomains do not get redirected?</p>

Can't you adjust the RewriteCond to only operate on example.com?
```
```
RewriteCond %{HTTP:Host} ^example\.com(.*) [NC]
```
```