Click to See Complete Forum and Search --> : http.conf


mooby
03-31-2003, 03:44 AM
hey all,

im trying to set up virtual hosts in apache on a windows NT machine. I have followed numerous tutorials and am 99% sure that the virtual host sections are correct.
BUT
It just wont work, i have set up one as the ip and want it to be redirected to h:/websites
and ive set up another with my domain and want it to be redirected to h:/websites/domain.

As i am sure i have the right set up in virtual hosts i was wondering if there is anything else i need to change in the conf file or hosts file to set it up so it works from a remote location, currently the ip and the domain both point to h:websites/domain so i think im missing something obvious

thanks for any help you can offer

Matt

Rune
03-31-2003, 09:50 AM
You could do it like this:
ServerName 123.45.67.890 (your IP here)

.
.
.

DocumentRoot "H:/websites"

.
.
.

NameVirtualHost *(use these "*" instead of IPs or domain names)

<VirtualHost *>
DocumentRoot "H:/websites"
</VirtualHost>

<VirtualHost *>
ServerName www.mydomain.com
ServerAlias mydomain.com *.mydomain.com
ServerAdmin admin@mydomain.com
DocumentRoot "H:/websites/domain"
DirectoryIndex index.html
</VirtualHost>
That way, any reference to your domain (www.mydomain.com, forum.mydomain.com, pics.mydomain.com, etc) will all get forwarded to the VirtualHost container for it, but anything else (like entering the IP instead of the domain name) will default to the other one, which has a different root directory. The first VirtualHost container is always the "default" that requests will be defaulted to if they don't match any other VirtualHosts.