Click to See Complete Forum and Search --> : Apache 2 - using virtual hosts and canonical names?


Rune
01-25-2003, 02:12 PM
I'm running Apache 2 on a Win2kAS machine and am currently hosting 3 domains on the one server. I've figured out how to use server name and canonical name settings for one domain name correctly ... I've figured out how to use virtual hosts for all 3 domain names correctly ...

... I just can't figure out how to use them together. :)

I want each virtual host to use it's own canonical name, ie when you visit www.mydomain1.com it'll show http://www.mydomain1.com/blahblahblah ... in the address bar. When you visit www.mydomain2.com it'll show http://www.mydomain2.com/blahblahblah ... in the address bar, etc.

But even though the 3 different domain names ARE being forwarded to their correct subfolders in my root folder and the correct index page for each domain is showing up ... I can't get canonical name to display right. Only way I can even get the virtual hosts to work at all is to set ServerName to the IP address (which there is only one of for the server) but then of course the IP shows up in the address bar instead of the site name.

I've tried commenting out THE ServerName and then specifying it seperately in each virtual host, but that didn't work. I've tried commenting out THE "UseCanonicalName On" and then specifiying it in each of the virtual host blocks, but that didn't work either. I'm stumped.

This is what I have in my virtual host blocks:


NameVirtualHost www.mydomain1.com
NameVirtualHost www.mydomain2.com
NameVirtualHost www.mydomain3.com

<VirtualHost www.mydomain1.com>
ServerName www.mydomain1.com
ServerAlias mydomain1.com forum.mydomain1.com *.mydomain1.com
ServerAdmin admin@mydomain1.com
DocumentRoot /Apache2/htdocs/
</VirtualHost>

<VirtualHost www.mydomain2.com>
ServerName www.mydomain2.com
ServerAlias mydomain2.com forum.mydomain2.com *.mydomain2.com
ServerAdmin admin@mydomain2.com
DocumentRoot /Apache2/htdocs/
</VirtualHost>

<VirtualHost www.mydomain3.com>
ServerName www.mydomain3.com
ServerAlias mydomain3.com forum.mydomain3.com *.mydomain3.com
ServerAdmin admin@mydomain3.com
DocumentRoot /Apache2/htdocs/
</VirtualHost>


P.S. The DocumentRoot for each is listed as the same because I have the domain forwarding on the DNS side specifying the subfolder to go to. ie www.mydomain1.com forwards to http://123.45.67.89/mydomain1/ , www.mydomain2.com forwards to http://123.45.67.89/mydomain2/ , etc.