Forum Moderators: phranque
NameVirtualHost www.example.gen.tr
<VirtualHost www.example.gen.tr>
ServerAdmin vampirhuma@example.gen.tr
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/Example"
ServerName example.gen.tr
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
#
NameVirtualHost www.example.org
<VirtualHost www.example.org>
ServerAdmin vampirhuma@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/Example2"
ServerName example.org
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
#
NameVirtualHost www.examplescorp.com
<VirtualHost www.examplescorp.com>
ServerAdmin scorp@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/syldatabase"
ServerName examplescorp.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
#
NameVirtualHost kayit.example.gen.tr
<VirtualHost kayit.example.gen.tr>
ServerAdmin vampirhuma@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/kayit"
ServerName kayit.example.gen.tr
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
#
NameVirtualHost sifre.example.gen.tr
<VirtualHost sifre.example.gen.tr>
ServerAdmin vampirhuma@example.gen.tr
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/pw"
ServerName sifre.example.gen.tr
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
[edited by: jdMorgan at 10:34 pm (utc) on June 11, 2004]
[edit reason] Removed specifics per TOS [/edit]
The only one attribute of the <VirtualHost> container is an ip address (or a wildcard character) and the port (if you leave it out it uses the value of the Port directive from your httpd.conf).
Virtual hosting can be implemented in three diferent ways:
Name based virtual hosting
Apache listens on all the specified ip and port combinations, and if a request comes through one of the ip/port combinations specified by the NameVirtualHost directive then it searches all the Virtualhost containers for a matching server name, and uses the one which is matched, or if there/s no match uses the first one which has the same ip and port specified as where the request is made through. In this scenario, your config looks like this:
NameVirtualHost *
<VirtualHost *>
ServerName www.domain1.com
DocumentRoot dev/null
</VirtualHost>
<VirtualHost *>
ServerName www.domain2.com
DocumentRoot dev/null
</VirtualHost>
NameVirtualHost *
<VirtualHost 192.168.0.1>
DocumentRoot dev/null
</VirtualHost>
<VirtualHost 192.168.0.2>
DocumentRoot dev/null
</VirtualHost>
<VirtualHost 192.168.0.2:8080>
DocumentRoot dev/null
</VirtualHost>
Unfortunately you did not posted your new virtual host which does not want to work, but I'll fixed the one you sent so you can try to add it again, an if it will not work come back with the faulty one.
NameVirtualHost [i]ip_address_pointing_to_the_server #1[/i]
...
NameVirtualHost [i]ip_address_pointing_to_the_server #n[/i]
<VirtualHost [i]ip_address_pointing_to_the_server #1[/i]>
ServerAdmin vampirhuma@example.gen.tr
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/Example"
ServerName example.gen.tr
</VirtualHost>
#
<VirtualHost [i]ip_address_pointing_to_the_server #1[/i]>
ServerAdmin vampirhuma@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/Example2"
ServerName example.org
</VirtualHost>
#
<VirtualHost [i]ip_address_pointing_to_the_server #2[/i]>
ServerAdmin scorp@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/syldatabase"
ServerName examplescorp.com
</VirtualHost>
#
<VirtualHost [i]ip_address_pointing_to_the_server #2[/i]>
ServerAdmin vampirhuma@example.org
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/kayit"
ServerName kayit.example.gen.tr
</VirtualHost>
#
<VirtualHost [i]ip_address_pointing_to_the_server #3[/i]>
ServerAdmin vampirhuma@example.gen.tr
DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs/pw"
ServerName sifre.example.gen.tr
</VirtualHost>
Try to implement the same into your server config, and if you still get stuck, tell us more about your environment (number of ip addresses, and the ip addreses of each domains pointing to your server) and someone will help you with this.