Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to have 2 web servers running on the same box with different ports and then use htaccess to tunnel traffic from 1 server to another based on a rewritecond? Basically when a certain condition is met I want the request to be handled by my other web server and I don't want to return a moved response.

share|improve this question
up vote 2 down vote accepted

Yes, it's possible. If the first server is Apache, you can use it as a reverse proxy using mod_proxy to do this.

ProxyPass /abc
ProxyPassReverse /abc

If your proxy requirement is more complex, you can also tell mod_rewrite to send the substitution part of the rewrite rule to mod_proxy with the "P" flag:

RewriteRule ^/abc$ [P]

It appears (I'm not familiar with litespeed) that the litespeed rewrite engine is identical to Apache:

So to test for the absence of a cookie, you'd use a Rewrite rule like so:

RewriteCond %{HTTP_COOKIE}       !^Your_Cookie_Name$
RewriteRule ^/(.*)     $1 [p]

There's an example of litespeed rewrite+proxy here:

share|improve this answer
What if I want to pass to the proxy only if a cookie is not set? Also the first server is litespeed. – Will Mar 21 '11 at 4:36
I've edited the answer with a cookie example and some links to litespeed. – Hari Mar 21 '11 at 5:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.