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?
ravenplConnect With a Mentor Commented:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.one\.com
RewriteRule .*{REQUEST_URI} [R=301,L]
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

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
All Courses

From novice to tech pro — start learning today.