mod re-write to redirect specific subdomains

I've got two sites &

I'd like to use mod re-write to re-direct all subdomain traffic on to

For instance, if someone typed in, it would redirect to

However, if they go to or simply just I'd like them to stay on and not be re-directed.

Here's some code I tried to write - but I know that I'm way off the beaten path.  Any thoughts?

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www..*
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]*).(com|com/)
RewriteRule ^.*$ http://%1.two/.com{REQUEST_URI} [R=301,L]
Who is Participating?
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.

I would recommend handling this at the DNS level...  ie: (free account starts with 5 credits) .... then you can redirect as necessary without straining your servers...

there's others too... easydns is another one that comes to mind...

from whichever standpoint...  as long as you can isolate x.domain.x.x.x.x with an ip address... with which you wish you direct traffic to... you should be able to manage all prefix domains to a particular ip regardless

and if your servers or sites are in disparate locations CNAME records come in handy too...

(once you setup a managed dns account, you will have to login to the registrar of the domain(s) in question and update the name servers to point to your new name servers)

however, this is a totally different approach than hard coding ....

if hard coding was my only option, i would do a page.redirect; once they landed at their predefined location..... (i'd have to check the syntax... ) on the html lvl...  log the visit etc, and pump that data back into your db

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.one\.com
RewriteRule .*{REQUEST_URI} [R=301,L]

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
ptowndesignAuthor Commented:
ravenpl --

I tried the code, but it didn't seem to work.  
well... 1st off, i'm obviously not able to answer your question specifically... sorry... but hopefully at least i'm learning something..... because for the solution i provided would also require you to run an IIS (basic windows web server) to dictate where to send the requests inside your dmz.. on the specific (apache/etc server) .... oh well... i see where i'm lacking on the apache side
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
Apache Web Server

From novice to tech pro — start learning today.