Forum Moderators: phranque

Message Too Old, No Replies

How to add a VirtualHost so it points to a certain file directory

Adding a virtualhost

         

gavinLive

5:23 pm on Aug 6, 2010 (gmt 0)

10+ Year Member



Hi, basically... I have my domain, [domain.com...] and I have another domain [otherdomain.com...] which both point to the same directory (C:/webserver/www/). But with [otherdomain.com...] I want it to go to C:/webserver/www/otherdomain/ instead. It is possible?
I heard that it could be done by editing the apache httpd.conf file and has something to do with VirtualHosts but I am not sure how.

:-) I don't really want to have to put in a php redirect or anything in the index.php and if it is the only way...

Thanks in advance

jdMorgan

5:54 pm on Aug 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See "Virtual Hosting" in the Apache server documentation at apache.org.

You can set up separate VirtualHost sections for each "domain," leaving the "main domain" first as the default vHost in case you get requests for undefined hostnames. Or you could set up a third vHost for this purpose.

The specific directive that will change inside the VirtualHost container is the DocumentRoot declaration, although you may wish to change other config settings as well.

So a good start might be to copy the existing <VirtualHost> container into one or two more containers, and then adjust the ServerName, ServerAlias, and DocumentRoot declarations to the "domains" and directory-paths that you want.

Jim

[edited by: jdMorgan at 6:03 pm (utc) on Aug 6, 2010]

gavinLive

5:58 pm on Aug 6, 2010 (gmt 0)

10+ Year Member



Thanks Jim... Again