Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I have a domain on my server (on its own virtualhost), e.g., which has a lot of subdomains with content on it.


This virtualhost looks like this:

 ServerAlias *
 DocumentRoot /var/www/

I want to put other domains on the server and have each of them link to a specific subdomain on I don't want it to redirect. I want a similar behavior as the [L,PT] flags on mod rewrite.

I've tried this:

 ReWriteEngine on
 RewriteCond %{HTTP_HOST} ^$ [NC]
 RewriteRule ^(.*)$$1 [PT,L]

But it is giving me a 400 Bad request error.

How would I configure such a virtualhost?

share|improve this question

If the following doesn't do what you want, please explain why.

<Virtualhost ...>
  DocumentRoot /www/sub1

<Virtualhost ...>
  DocumentRoot /www/sub1
share|improve this answer
The subdomains on are created dynamically (my database stores which subdomains exist), that's why I'm using ServerAlias * There is no physical document root for every subdomain. – Laurent Van Winckel Nov 5 '10 at 12:36

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.