# Issue with vHosts and Sub Domains in Apache



## Phi Kai (Sep 10, 2008)

So I've been working on getting my Apache server set up a little differently. I wanted to do a subdomain with my domain. I read online and got some of it figured out. I have the non-live versions working fine. But for some reason, the live version isn't working properly.

sub.domain.com ---> goes where it should
domain.com ---> changes browser address to localhost 
sub.localhost ---> goes where it should
localhost ---> goes where it should

I'm not sure what I screwed up, but if someone could take a look and help me out that would be great.


*Windows Hosts File*

```
192.168.244.148 edlindustries.com
192.168.244.148 www.edlindustries.com
192.168.244.148 forums.edlindustries.com
127.0.0.1 localhost
127.0.0.1 forums.localhost
```

*Apache vHosts File*

```
#
# Use name-based virtual hosting.
#
NameVirtualHost edlindustries.com
NameVirtualHost forums.edlindustries.com
NameVirtualHost 127.0.0.1

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost edlindustries.com>
DocumentRoot "C:/wamp/www"
ServerName edlindustries.com
ServerAlias www.edlindustries.com
<Directory "C:/wamp/www/">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost forums.edlindustries.com>
DocumentRoot "C:/wamp/www/forums"
ServerName forums.edlindustries.com
<Directory "C:/wamp/www/forums">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 127.0.0.1>
DocumentRoot "c:/wamp/www"
ServerName localhost
<Directory "C:/wamp/www/">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 127.0.0.1>
DocumentRoot "C:/wamp/www/forums"
Servername forums.localhost
<Directory "C:/wamp/www/forums">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
```


----------

