Domains

1. The Model T

If you just want to declare your domain with a www.yourdomain virtual host serving out of ~/public_html/ and your-hcoop-username@yourdomain mail forwarded to your mailbox, use:

dom "yourdomain" with
end;

Or, if you don't want any mail to be forwarded to your mailbox, use:

dom "yourdomain" where
  DefaultAlias = false;
with end;

2. Upgraded Model T

If you like everything dom gives you but want to add additional configuration, include it between with..end. For instance, to add an extra web virtual host other:

dom "yourdomain" with
  web "other" with
    (* More configuration could go here *)
  end;
end;

3. Model T with customized www.yourdomain

You wouldn't want to copy the last example with "www" instead of "other", because dom already creates a www vhost. Instead, there's a more convenient way to configure this most common of vhosts:

dom "yourdomain" where
  DocumentRoot = "/my/custom/docroot";
  (* See "Bucking all the trends" in the Apache section for other options you can
     use like DocumentRoot. *)
  WWW = begin
    alias "/from" "/to";
    alias "/from2" "/to2";
    (* These are just examples.  Arbitrary vhost config goes here. *)
  end
with
  (* And other domain configuration can go here, including more vhosts. *)
end;

4. Model T with redirect from www.yourdomain to yourdomain

To redirect all URLs from http://www.mydomain/some/path/ to http://mydomain/some/path/ you need to disable the automatic creation of the www host, and then create it manually specifying a permanent redirect rule.

dom "mydomain.com" where
 CreateWWW = false;
with
 vhostDefault with
 end;

 web "www" with
   rewriteRule "^(.*)$" "http://mydomain.com$1" [redirectWith permanent]
 end;
end;

5. Attack of the Model T Clones

We can take the Model T and use it with some alternate names for the domain we're configuring.

dom "yourdomain" where
  Aliases = ["yourotherdomain", "yourotherotherdomain"]
with
end;

A single Apache virtual host is created, answering to multiple names. Other configuration is duplicated like you had entered it in a separate dom block for each alias.

6. Subdomain Redirection

This example aliases a subdomain and redirects it to the "www" virtual host. This means that when accessing yourSubdomain.yourdomain.com you will actually be receiving content defined by www.yourdomain.com.

dom "yourdomain.com" where
  CreateWWW = false
with
  dnsIP "yourSubdomain" web_ip;
  web "www" with
    serverAlias "yourSubdomain"
  end
end;

7. The Do-It-Yourself

The lowest-level way of configuring a domain is the domain directive, which does nothing but set up basic DNS parameters and provide a space for including further directives. You shouldn't use the domain directive unless you really know what you're doing when it comes to Internet protocols, and you have a good reason not to like the defaults that dom includes.

domain "yourdomain" with
  (* Your directives here *)
end;