Subdomains are a great way to split up different kinds of content – like your default homepage, your blog, and your music collection. To set it up, you have to edit httpd.conf (the Apache configuration file.)
What you need to do is set up the different hosts (they’re called “Virtual Hosts”) and tell Apache which directories match. For example, if I wanted myname.example.com to map to a homepage and blog.myname.example.com to map to my blog and jukebox.myname.example.com to map to my music collection, I’d add the following to httpd.conf:
<VirtualHost *> DocumentRoot /Library/WebServer/example.com ServerName myname.example.com </VirtualHost> <VirtualHost *> DocumentRoot /Library/WebServer/blog.example.com ServerName blog.myname.example.com </VirtualHost> <VirtualHost *> DocumentRoot /Users/gina/Music/iTunes ServerName jukebox.myname.example.com </VirtualHost>
There my DocumentRoot is the file path to the folder that holds the sites’ files. (I’m on a Mac right now, on a PC it would be C:\ etc.)
A word to the wise: back up your working httpd.conf file first before you start editing it. It’s a finicky beast sometimes, one that’s eaten hours of my life because I didn’t back up first.