[Techtalk] Apache and name based virtual hosts

tiera tiera at comhem.se
Tue Sep 23 21:15:00 EST 2003


Hi

I'm trying to configure Apache (Apache/2.0.40 (Red Hat Linux)) to use name 
based virtual hosts. I tried to follow the apache documentation but I must 
have done something wrong because things aren't working. 
My default domain should be example1.com and the other domain should be 
example2.com. 
This is what I've added to the end of my httpd.conf: 

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot /var/www/html
    ServerName example1.com
</VirtualHost>

<VirtualHost example2.com:80>
    DocumentRoot /var/www/example2
    ServerName example2.com
    ErrorLog logs/example2-error_log
    CustomLog logs/example2-access_log common
</VirtualHost>

And I also want ssl for the default domain so for that I have:
<VirtualHost example1.com:443>
DocumentRoot "/var/www/html"
ServerName example1.com:443
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
[snip]
</VirtualHost>

Apache starts ok and everything. But if i try to go to example1.com/page.html 
I get a 404 error that gives example2.com as the server adress. If I visit 
https://example1.com/page.html everythings ok. If I visit 
https://example2.com/page.html I get the same page as before, which I don't 
think should work because page.html is in the document root for example1.com. 
So obviously there's something I've misunderstood. But I've done just as the 
example in the Apache docs except that I've put :80 at the end because I also 
have the ssl configuration. I've tried to put example1.com instead of the * 
in the above configuration directives, but then I get different errors about 
missing NameVirtualHost and that example2.com doesn't belong and so on.

Does anyone see what I am doing wrong? 

/Tiera




More information about the Techtalk mailing list