So I’ve done a bunch of google and forum searching on this, but I’m stuck! I’m just trying to do simple name-based virtual hosting (different domains/content, same IP).
What I’ve done is uncomment the “NameVirtualHost *:80” line in listen.conf. Then I have one file “domain.conf” in vhosts.d/ with:
<VirtualHost *:80>
ServerName www.domain1.com
DocumentRoot /srv/www/htdocs/domain1
<Directory "/srv/www/htdocs/domain1">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.com
DocumentRoot /srv/www/htdocs/domain2
<Directory "/srv/www/htdocs/domain2">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Now, I actually have many domains, but these are the only 2 vhosts I set up. No matter what domain I go to (even if I just use my IP), it uses whichever <VirtualHost> I put first, in this case, “www.domain1.com”'s root of htdocs/domain1. If I switch that around, and put domain2 first, everything gets directed to htdocs/domain2.
I have tried:
using * instead of *:80
separate .conf files for each domain (it just uses the first alphabetically)
I don’t have apache server installed right now, but I remember using virtual hosts which I set up using yast. So instead of editing config files manually, I would recommend doing your setup through yast. That would be more productive. If you can’t figure out how to do that, I might install apache and try to figure out how did I do it earlier.
I did my virtual host configuration just fine. I far as I can see, yast only created too files inside vhosts.d called www.yasar1.comwww.yasar2.com, their contents are:
I figured out the problem. It’s something related to the headers not being passed on to my server, so it’s not getting the proper domain name Unrelated to vhosts config
I can’t see anything weird on your setup, are you trying to access your virtual host from your server machine, or from some other machine. If you are trying to access your virtual machines from your own server, that might be causing problems. If you want, you can send your external ip with pm to me, and also your server names so I can check out if it works or not.
Edit after seeing your edit: Hmm that is nothing we can do about it than.
Yes, for virtual hosting to work, the client has to send the line Host: <virtual.domain> to the server. All web browsers do this when you put the virtual domain as part of the URL. If you were doing testing with telnet or whatever you have to add this Host: line.