Thanks Brian!
I got the whole thing sorted out by putting all the Virtual Host
declarations inside one file instead of splitting them into separate
files. This way, I always know which is the "first" or "default" Virtual
Host. Not an elegant solution, but it works.
After some more Googling, I realized that OpenSUSE's Apache actually
looks at the filename and sorts it alphabetically, so your suggested
practice of naming the first Virtual Host as "_default.conf" would work.
There are still a few odd quirks in OpenSUSE's Apache, but I think I
have a handle on this now.
Thanks and Best Regards,
pascal chong
----- Original Message -----
From: "Brian K. White"
Hi all,
So, I setup Apache on my OpenSUSE 11.4 server at home, wanting to experiment with several php and perl apps (hence the Virtual Hosting config), when I found some strange behaviour with Virtual Hosting.
I have a default configuration in Apache which I can access using hostorig.domain.tld (not the real name of course). I create a Virtual Host, host1.domain.tld and put an index.html inside. It works, so far so good.
Ok, now, I add another Virtual Host, host2.domain.tld, and things start to get strange. When I open a browser and go to "http://hostorig", I get "http://host1" instead. "http://host1" still points to the right place, and "http://host2" point to the right place too.
A bit of Googling around leads me to a site that says that the order of the<VirtualHost> stanzas is significant. If Apache does not understand which Virtual Host the user is requesting, it will default to the first <VirtualHost> declaration.
Now, in OpenSUSE, the order of the Virtual Hosts is not so clear because they are all contained in separate .conf files inside /etc/apache2/vhost.d. If I wanted one of the Virtual Hosts here to be the "first" Virtual Host declared, what do I do?
Since this is a home setup, it's not really that important, but it is annoying me like crazy. If anyone here can give me any information on why all this is happening and how I can setup a Virtual Host that Apache will "default" to when it doesn't understand the destination (or just setup Virtual Hosts better), please help!
Thanks in Advance, pascal chong
I have this in /etc/apache2/httpd.conf :
[...]
# define a default do-nothing "vhost" before including any possible
config files
# so that defaults will end up coming from the main config files instead
# of requiring a vhost.conf with a special filename that will get read
# before others