# Subdomains



## amcavoy (Nov 28, 2005)

I host my own website, which is a subdomain from dyndns.org. My address is apm.homedns.org. If I wanted to, for instance, create mail.apm.homedns.org, how could I do this? It won't let me do so on dyndns.org (or I don't know how to) so I figured I could do it with my apache server. Any help is appreciated :smile:

Thank you.


----------



## Skie (Mar 15, 2003)

You'll need the ability to create a subdomain through dyndns.org before it can be used by your apache server. Once that's done, you'll need to associate your MX record to that subdomain. Or, if you don't mind, you can just use your apm.homedns.org as your MX record without creating a subdomain. Either method will work, but you'll need the ability to create that MX record.


----------



## DumberDrummer (Oct 27, 2003)

ok, this should work in both apache 2 and apache 1.x

In the apache config file, you will need to add this code:


```
<VirtualHost IPADDRESSHERE:80>
DocumentRoot /path/to/subdomain/directory
ServerName www.myserver.com
</VirtualHost>
```
Then the server will interperet any calls to that subdomain as actually asking for that directory. As long as its in the htdocs folder, all should work well!


----------



## amcavoy (Nov 28, 2005)

Add that to the "httpd.conf" file? I tried to do that, but it didn't work. When I enter the directory /path/to ... should I assume I'm already in my root folder or should I enter the whole thing? For instance, if I have my root at /var/www, and I want it to redirect to /var/www/myfolder, would I do this:

<VirtualHost IPADDRESSHERE:80>
DocumentRoot /var/www/myfolder
ServerName www.myserver.com
</VirtualHost>

or

<VirtualHost IPADDRESSHERE:80>
DocumentRoot /myfolder/
ServerName www.myserver.com
</VirtualHost>

Thanks again.


----------



## DumberDrummer (Oct 27, 2003)

the full path, so the first one. 

Also note that the server name needs to include the subdomain, so its not www.myserver.com, but mysubdomain.myserver.com


----------



## amcavoy (Nov 28, 2005)

I added the following to the end of my httpd.conf file in the apache folder:

<VirtualHost 24.183.179.125:80>
DocumentRoot /var/www/apache2-default
ServerName test.apm.homedns.org
</VirtualHost>

However, when I type in 'test.apm.homedns.org' I just get the default directory which is /var/www. Any ideas on why this is happening?

Thanks again.


----------



## DumberDrummer (Oct 27, 2003)

try replacing the ip with an asterisk *

That's how I have it setup in my httpd.conf.


----------



## amcavoy (Nov 28, 2005)

OK that worked great. Just one more question: If I have multiple subdomains, how do I input the code? Do I just keep adding virtualhost tags?

Thank you.


----------



## Skie (Mar 15, 2003)

Yes, you would have multiple VirtualHost lines. They'll need to be modified slightly however. Mainly the ServerName and the DocumentRoot lines, if I remember correctly. I'm too lazy to look it up for sure right now. :1angel:


----------



## DumberDrummer (Oct 27, 2003)

you remember correctly.


----------



## amcavoy (Nov 28, 2005)

Modified how?

Thanks again.


----------

