troubleshooting Question

Redirect Non-WWW to WWW in Web.config (Except one spesific subdomain)

Avatar of webressurs
webressursFlag for Norway asked on
Microsoft IIS Web ServerASP.NET
12 Comments1 Solution1101 ViewsLast Modified:
On my Windows 2012 server I have installed the URL Rewrite module in IIS. I have followed this guide to redirect non-www to www in web.config:

So far, so good!

The only problem is that we also host the subdomain "". This API stops working when I apply the <rewrite> code in web.config. My question is: How can I change the <rewrite> code below to redirect non-www to www, except for the subdomain ""?

        <rule name="RedirectToWWW" stopProcessing="true">
          <match url=".*" ignoreCase="true" />
            <add input="{HTTP_HOST}" pattern="^$" />
          <action type="Redirect" url="{R:0}" redirectType="Permanent" />

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros