# Subdomains + Apache



## Crooksey (Sep 21, 2010)

So I have a vhosts.conf files that looks like..


```
<VirtualHost *:80>
      ServerName www.sole.co.uk
      DocumentRoot /home/luke/rails/public
      RailsEnv development
      <Directory /home/luke/rails/public>
         AllowOverride all
         Options -MultiViews
      </Directory>
   RailsBaseURI /
   </VirtualHost>

<VirtualHost *:80>
ServerName payments.solen.co.uk
DocumentRoot /home/luke/payments
</VirtualHost>
```

I have created my subdomain of payments with my registrar. But my website for domain.com and subdomain.domain.com have the same ip address so the cname records are the same.

How do i configure my freeBSD server to point the subdomain to the right location?


----------



## Dereckson (Sep 21, 2010)

As you did, witn vhosts, adding the directive NameVirtualHostin your httpd.conf (e.g. before your vhosts declaration):

```
NameVirtualHost *:80
```


----------



## Crooksey (Sep 21, 2010)

So all i need to add is "NameVirtualHost *:80" to httpd.conf ?


----------



## Dereckson (Sep 21, 2010)

Indeed (and then of course restart apache, with 
	
	



```
apachectl graceful
```
 for example).

You'll find a more detailed information in Apache HTTP Server documentation at Name-based Virtual Host Support section.


----------

