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

Is there a best practice (for performance reasons or otherwise) for choosing between using a Virtual Host or rewrite for pointing a subdomain to a folder in the root directory?

I.e., -> public_html/ -> public_html/

The above can be accomplished by setting up two virtual hosts or by using a single virtual host and just having a rewrite set up to point to the correct sub directory.

My question originally concerned Apache, but I would be interested in knowing if there's a best practice for Nginx's Server Block as well.

share|improve this question
up vote 1 down vote accepted

I'd use two virtual hosts because rewriting tends to get messy pretty fast.

share|improve this answer

Rewrite the subdomain should be faster because it does not need to go and read the configuration of your virtual host, still , might be miliseconds (unless the apache is not working well), otherwise I think the best is to do it in a virtual host,due you can manage it from a better way and you dont need to wait for refresh.

share|improve this answer
Not convinced. If you do a rewrite in .htaccess that'll be slower. If you do it in the apache config it still needs to be read and might generate an internal second request - depending on the nature of the redirect. – Steve Kemp Sep 11 '12 at 13: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.