Virtual Hosts & Subdomains

Robert Bonomi bonomi at
Sat Mar 17 06:59:22 UTC 2012

David Hughes <dghughes82 at> wrote
> Hi all,
> Forgive me if this is slightly off-topic, but I wonder if I could 
> trouble you for some advice about setting up website subdomains with 
> Apache. I currently have a website up and running on a jailed VPS; I've 
> been trying to set up subdomains so that one might navigate to a certain 
> area of the site by using a URL of the form rather 
> than
> I've tried reading the official Apache documentation and a number of 
> tutorials that I've found online, but nothing I've tried has worked so 
> far. Do Virtual Hosts behave differently if they're within a jail? Or do 
> I need some sort of DNS registration for subdomains? I've been trying to 
> figure it out by myself, with little success so far - I'm quite new to this.

This takes several things to make it work.
  1) You must have DNS entries for all the various  {foo}.domian.tld 
     paths that you intend to use.  CNAMEs that point to  domain.tld
     will work, combined with an 'A' (and/or 'AAAA') records for the
     domin.tld  name itself. You'll also need an rDNS record for the
     IP address -- that points to  domiain.tld .

     This stuff is necessary so that a web browser knows how/where to
     find the server for  {foo}.domiain.tld .

  2) then you need to tell Apache that it is to services requests for
     multiple domain names.  This is what the 'virtualhost' stuff in
     the Apache config file does.

  3) the web browser *MUST* generate 'HTTP/1.1' queries -- where the
     hostname that one is expecting a response from is, itself, included
     in the request that is sent to the server at the 'resolved' IP

More information about the freebsd-questions mailing list