Take the 2-minute tour ×

Currently, I have a single production website running on Apache/2.2.3. I use mod_rewrite extensively and have about 200 RewriteRule's.

Now I need to add another website from a second domain name to the server, and I'd like to use virtual hosts to do that. It's 2 sites, 2 domain names, one webserver.

The existing site is running perfectly, and I don't want to disturb it if I don't have to.

My questions:

Do I need to move the existing website into a <virtualhost> container? Or is there any way to create a new virtual site for the new domain, and leave the existing as is?

If I do need to move the old site, do I have to move all the redirects and the whole <Directory "/var/www/html"> section into the virtual host container ?


share|improve this question
Are you planning IP-based or named-based virtual hosting? –  dawud Apr 17 '13 at 19:09

2 Answers 2

up vote 1 down vote accepted

Directory directives outside of the VirtualHost context will be used by default by virtual hosts unless they are overwritten. That's not the case for rewrite rules, if I recall correctly.

In any case, it is a good practice to keep virtual host specific configuration separated, as this keeps things organized and avoids confusion. It is common nowadays to have virtual hosts split into different files and some distributions provide this environment by default.

share|improve this answer

You should test this in your exact environment but I do have a server set up like what you describe. There are a bunch of configuration in the "default" configuration (i.e. straight in httpd.conf and not within a VirtualHost). And then I have under sites-enabled some configuration files with VirtualHost entries which are like:

ServerName mysecondserver


And it works well.

share|improve this answer

Your Answer


