web.config file

I need a rewrite rule and can't get the syntax to remove the www OR ANY subdomain from domain.com
so www.domain.com or ww3.domain.com or xyz.domain.com will all rewrite to domain.com

thanks
LVL 25
dgrafxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aaron TomoskyDirector of Solutions ConsultingCommented:
Use the negate="true" flag to redirect anything not domain.com to domain.com like in the canonical host name example here
http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/
dgrafxAuthor Commented:
I see that I rewrote my question and left out a crucial bit

Is there a way to use this to rewrite multiple domains in one rule?
i.e. "domain1.com|domain2.com|domain3.net"
and the action is to rewrite back to origin domain?
www.domain.com would be domain.com & www.domain3.net would be domain3.net

Thanks ...
dgrafxAuthor Commented:
Because of multiple domains the rule you pointed to doesn't work out.
All sites relocate to the domain in the first rule for some reason.
It works for just the one domain though.

I am using this which seems to work for multiple domains:

                        <rule name="SEO - HTTP canonical redirect" stopProcessing="true">
                              <match url="^(_*)(.*)" />
                              <conditions logicalGrouping="MatchAll" trackAllCaptures="true">
                                    <add input="{HTTP_HOST}" pattern="^www\.(.*)" />
                                    <add input="{HTTP_METHOD}" pattern="GET" />
                                    <add input="{SERVER_PORT}" pattern="80" />
                              </conditions>
                              <action type="Redirect" url="http://{C:1}/{R:2}" />
                        </rule>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Aaron TomoskyDirector of Solutions ConsultingCommented:
That should work. You could also use something like ^ww?\.(*.)
Many different ways to do regex
dgrafxAuthor Commented:
see my last post
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.