0

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.,

www.domain.com -> public_html/domain.com/
sub.domain.com -> public_html/sub.domain.com/

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.

2 Answers 2

1

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

0

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.

1
  • 1
    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.
    – user9565
    Sep 11, 2012 at 13:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .